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

Please update file-loader to latest version #363

Closed
alexander-akait opened this issue Feb 4, 2020 · 14 comments · Fixed by #432
Closed

Please update file-loader to latest version #363

alexander-akait opened this issue Feb 4, 2020 · 14 comments · Fixed by #432

Comments

@alexander-akait
Copy link

Latest version of file-loader is https://github.com/webpack-contrib/file-loader/blob/master/package.json#L3. We switch to ES modules syntax and it is allow to tree shake code, I would suggest to do it too:

  • update file-loader to latest version, introduce esModule option (default value is false) and do minor release
  • switch esModule to true and do major release
@bhovhannes
Copy link
Owner

bhovhannes commented Feb 4, 2020 via email

@alexander-akait
Copy link
Author

@bhovhannes yes, but i recommend to use the 5 version

@bhovhannes
Copy link
Owner

Temporary solution was to bump file-loader version to v5, passing esModule=false to file-loader.

That was done in #346 .

I am not ready to enable esModule=true by default as not every consumer if this package has babel loader. And thus I am not going to introduce any new option to this loader at this moment. I plan to think about this when webpack 5 will be released.

@evilebottnawi, just out of curiosity, do you have any evidence showing that writing code with export default ... contributes better to bundle size?

@alexander-akait
Copy link
Author

alexander-akait commented Feb 7, 2020

@bhovhannes

I am not ready to enable esModule=true by default as not every consumer if this package has babel loader.

You don't need babel for import, webpack handle that on own side. We support import ... from ... and @import().then() since webpack@4 without any additional loaders.

just out of curiosity, do you have any evidence showing that writing code with export default ... contributes better to bundle size?

Yes, it is reduce bundle size - https://webpack.js.org/plugins/module-concatenation-plugin/. It is allow remove unnecessary module and include value of module directly. Less modules - less size- fast runtime

@bhovhannes
Copy link
Owner

Thanks for info.
Then why esModule option is not true by default in file-loader?

@bhovhannes
Copy link
Owner

I mean it was introduced to be false by default and then was made to be true. What was the reason for that?

@alexander-akait
Copy link
Author

alexander-akait commented Feb 7, 2020

Module concatenation, simple example

string.js

export default "text";

index.js

import text from './string.js';

console.log(text);

When you run webpack in production mode and got only one module:

index.js

var text_module_concatenation_variable = 'text';

console.log(text);

No extra module. It is very very very simple case.

@bhovhannes
Copy link
Owner

Thanks for example. I am trying to understand why you suggest to release 2 versions and introduce a new option - esModule (like it was done in file-loader), if it works ok starting from webpack 4.

Well yes, if I care about folks using webpack 3 I should probably do like that and have that option in place.
However if I support only webpack 4 and above, why not to always pass esModule=true to file-loader?

@alexander-akait
Copy link
Author

However if I support only webpack 4 and above, why not to always pass esModule=true to file-loader

Some other loaders can't support ES module import so it should be setup from configuration

@bhovhannes
Copy link
Owner

Which loaders? Can't we try to upgrade them as well?

@alexander-akait
Copy link
Author

@bhovhannes Any, any developer can create an own loader, so we can't update them, just introduce new option and do it true by default in next major release

@bhovhannes
Copy link
Owner

bhovhannes commented Feb 7, 2020 via email

@alexander-akait
Copy link
Author

All popular loaders inside webpack-contrib and they support esModule 👍

bhovhannes added a commit that referenced this issue Nov 26, 2020
BREAKING CHANGE: this changes loader behavior when it falls back to file-loader. New behavior allows better tree-shaking.
@bhovhannes bhovhannes mentioned this issue Nov 26, 2020
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

Successfully merging a pull request may close this issue.

2 participants