webpack-contrib / file-loader

File Loader
MIT License
1.86k stars 255 forks source link

More documentation around esModules and their behavior please #370

Closed tstirrat15 closed 4 years ago

tstirrat15 commented 4 years ago

Documentation Is:

Please Explain in Detail...

In v5 esModules became a default. That broke my application, and making it false fixed it, but I have no idea why, and the documentation isn't clear on this note.

Your Proposal for Changes

Answers to questions above. I'm happy to (re)write them into the documentation.

alexander-akait commented 4 years ago

What does an esModule mean in the context of file-loader?

From docs:

By default, file-loader generates JS modules that use the ES modules syntax. There are some cases in which using ES modules is beneficial, like in the case of module concatenation and tree shaking.

How would it be imported and used? Is it meant for end consumption (i.e. being a loader by itself), or is it more meant for chaining?

Always yes.

When would the features esModule enables (like tree-shaking) be used? We're primarily using file-loader for image references, and it isn't clear where or how tree-shaking would happen when your imports are singular.

How tree-shaking works is out of the repo.

You can find a lot of articles about tree shaking and import/export

tstirrat15 commented 4 years ago

Always yes.

Is that yes to end consumption or is that yes to chaining? I think that would answer my question.

rightaway commented 4 years ago

Are we able to use import() function or only import statement? I get src="[object Promise]" as the output when I use import() even though I have esModule: true.

alexander-akait commented 4 years ago

@rightaway update html-loader to latest version

rightaway commented 4 years ago

I'm not using html-loader. You mean file-loader? I'm using latest 6.0.0. This is in a Vue template file btw.