Webpack.js.org: It is unclear what the file-loader .esModule option does

Created on 17 Apr 2020  路  3Comments  路  Source: webpack/webpack.js.org

__Feature to document__

https://webpack.js.org/loaders/file-loader/#esmodule

__Author(s)__

-

__Additional information__

As said in the feature description:

By default, file-loader generates JS modules that use the ES modules syntax.

I don't get what that means, does the file-loader generates a javascript module? Am I shipping a module in the browser? Or it generates a modules that is later webpack bundles?

[x] I am willing to work on this issue and submit a pull request.

Most helpful comment

webpack support import and require statements, using import allow to concatenate modules (less modules and runtime).

esModule:

  • false => module.export = "path/to/file.ext";
  • true => export default "path/to/file.ext";

All 3 comments

webpack support import and require statements, using import allow to concatenate modules (less modules and runtime).

esModule:

  • false => module.export = "path/to/file.ext";
  • true => export default "path/to/file.ext";

The example cleared it up! I will make a PR and update the docs with it

Nevermind it's on the README of file-loader

Was this page helpful?
0 / 5 - 0 ratings