webpack-5 and webpack-4 compatibility issue
This is an example library built with webpack 5 to demo an issue when consumed in an app that uses webpack 4.
- In module directory is a js module that is bundled with webpack 5.
- In library directory is a js library that is bundled with webpack 5 and re-exports the webpack-5 bundled module, leaving it as external.
- In app directory is a js app that is bundled with webpack 4 that tries to use module through library.
Repro steps:
-
cd app; -
npm ci; -
npm start; - Open
http://localhost:8080/, see error in console:Uncaught TypeError: i[e] is not a function
Conditions necessary to reproduce the issue:
-
moduleandlibraryare bundled with webpack@5 -
libraryis bundled with TerserPlugin withkeep_fnames: true -
libraryhas a async loaded module -
appis bundled with webpack@4