🐛 getBundles shouldn't require webpack #31
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The below import is failing in production
17:57:36 Error: Cannot find module 'webpack/package.json' 17:57:36 Require stack: 17:57:36 - /src/node_modules/react-loadable-ssr-addon/lib/ReactLoadableSSRAddon.js 17:57:36 - /src/node_modules/react-loadable-ssr-addon/lib/index.js
Why
This library is exported as CommonJS, which means treeshaking is not supported. When importing
getBundles
from theindex.js
as described in the README, the moduleReactLoadableSSRAddon
is also loaded which was requiring webpack (a devDependency) during server execution in production (where devDependencies are pruned).A better fix would be to export this library to ESM as well, and define a
"module": "./esm/index.js"
export in the package.json, along with a"sideEffects": false
to allow proper importing of named exports.Workaround
To workaround this issue, I had to change my import to
Checklist
errors
orwarnings
approved terminology
unit tests
, if apply.Emojis for categorizing pull requests:
⚡️ New feature (
:zap:
)🐛 Bug fix (
:bug:
)🔥 P0 fix (
:fire:
)✅ Tests (
:white_check_mark:
)🚀 Performance improvements (
:rocket:
)🖍 CSS / Styling (
:crayon:
)♿ Accessibility (
:wheelchair:
)🌐 Internationalization (
:globe_with_meridians:
)📖 Documentation (
:book:
)🏗 Infrastructure / Tooling / Builds / CI (
:building_construction:
)⏪ Reverting a previous change (
:rewind:
)♻️ Refactoring (like moving around code w/o any changes) (
:recycle:
)🚮 Deleting code (
:put_litter_in_its_place:
)