pixiebrix / eslint-config-pixiebrix

Custom eslint config, to be used with Prettier
MIT License
1 stars 1 forks source link

Ensure `import()`ed dependencies are always dynamically imported #208

Open fregante opened 8 months ago

fregante commented 8 months ago

If you first import('react') and then import "react" in the same bundle, Webpack will not create a secondary chunk, it will just inline it.

In a large application, it's not easy to keep track of all the import decisions, so one optimization (deferred loading via import()) can be undone and left unnoticed forever.

We can now enforce that some dependencies are always dynamically imported:

Both of these are enforceable via no-restricted-syntax

Related