Closed FezVrasta closed 5 years ago
We recommend using dynamic import()
as a way to avoid using CommonJS. Although since CommonJS is supported everywhere you can use sideEffects
, we recommend using require
, instead of importing a module and having a bundler tree-shake it out.
I'm sorry you decided to dismiss this issue so quickly.
For anyone interested in a solution to this problem, I published react-axe-es
on npm, which is a thin wrapper around react-axe
, with the sideEffects
flag set.
https://www.npmjs.com/package/react-axe-es
I also published a list of not suitable approaches with related explanation of why they are not a good solution to the problem, just in case the maintainers of this library ever decide to revisit their decision.
Given this ES modules code:
If the app is built in
production
mode, thereact-axe
package will not get stripped out from the bundle.If this package defined
sideEffects: false
in itspackage.json
, it would help webpack and Terser to dead code eliminate it.This is needed in projects that don't make use of RequireJS imports, but only use standard ES modules imports.