Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2: There's no bundling + tree shaking without minify-ing? #3459

Closed
tunnckoCore opened this issue Dec 11, 2016 · 6 comments
Closed

v2: There's no bundling + tree shaking without minify-ing? #3459

tunnckoCore opened this issue Dec 11, 2016 · 6 comments

Comments

@tunnckoCore
Copy link

As far as I understand last weeks.. There's no way to make a bundle that will have "tree shaking" enabled without the minifying? It not looks cool to me. I tried bundling without minifying and it seems it is not tree-shaked.

Or if it is possible, how? Some examples? I'm talking for v2.

@zhaoshengjun
Copy link
Contributor

As far as I know, the tree shaking only happens in minifying. In normal bundle, you can see the part of code has been marked as unused harmony export, but it is still there.

Technically it can be done.

@tunnckoCore
Copy link
Author

As far as I know, the tree shaking only happens in minifying.

Exactly.

In normal bundle, you can see the part of code

Yea, seen that.

@ematipico
Copy link
Contributor

ematipico commented Dec 12, 2016

Yeah I confirm, tree shaking results can be seen during final build for production.
In development, to see if three shaking is working, what I usually do is to try to export a fake function from a module that you are already using:

import { fakeFunc } from './myModule' 
console.log(fakeFunc)

And you should get a warning from webpack inside the console

@sokra
Copy link
Member

sokra commented Dec 13, 2016

You could also use --display-used-exports, which display information about tree shaking in the output

@sokra sokra closed this as completed Dec 13, 2016
@tunnckoCore
Copy link
Author

Omg, seriously. I know it is wokring, that's not the case. The case is that I want tree-shaked bundles without minifying - intentionally.

@sokra

display information about

What information? First it seems it does nothing for me, output is absolutely the same; Second don't want "information", I want real working bundle :D

~/code/foobar master ✓ ✗  
% ❯ webpack --entry ./index.js --output-filename bundle.js --target node                               December 13, 16:58:04
Hash: 9567831ddc533348d9a4
Version: webpack 2.1.0-beta.27
Time: 307ms
    Asset     Size  Chunks             Chunk Names
bundle.js  29.7 kB       0  [emitted]  null
  [15] ./index.js 2.73 kB {0} [built]
    + 15 hidden modules
~/code/foobar master ✓ ✗  
% ❯ webpack --entry ./index.js --output-filename bundle.js --target node --display-used-exports        December 13, 16:58:38
Hash: 9567831ddc533348d9a4
Version: webpack 2.1.0-beta.27
Time: 303ms
    Asset     Size  Chunks             Chunk Names
bundle.js  29.7 kB       0  [emitted]  null
  [15] ./index.js 2.73 kB {0} [built]
    + 15 hidden modules
~/code/foobar master ✓ ✗  
% ❯

@paztis
Copy link

paztis commented Jan 26, 2018

I'd like to do the same.
As the tree shaking cleanup is only done by the uglify-webpack-plugin, is there a way to let the build in dev mode, manually add the ugluify plugin and configure it to only do dead code cleanup (no mangling, no compress) ?

I search how uglify is configured in prod mode (or at least with the --optimize-minify option) and it seams to be all the default options only source-map is updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants