You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the latest versions of Parcel 2, dependencies are incorrectly excluded from code split bundles and Worker bundles that are descendants of that code split when scope hoisting is disabled. This triggers a Cannot find module '[id]' on page load on sites built with the parcel build command.
Scope hoisting is still really buggy for us and we haven't been able to debug that, so it's disabled. I'll likely submit a separate issue for that.
Parcel should include pertinent dependencies in split bundles and Worker bundles that descend from those.
😯 Current Behavior
A bunch of dependencies are excluded.
To try this out, copy this repository into your parcel/ repository at packages/examples/, cd into the directory, and run:
yarn run parcel build --no-scope-hoist --no-cache index.html
You will get output similar to this:
dist/browser/index.fe0b0221.js 70.25 KB 2.57s
├── ../../../node_modules/lodash/lodash.js 69.08 KB 417ms
└── Code from unknown sourcefiles 1.17 KB 0ms
dist/browser/index.85b8c16e.js 3.8 KB 974ms
├── Code from unknown sourcefiles 1.29 KB 0ms
├── ../../runtimes/js/src/JSRuntime.js 625 B 22ms
├── ../../runtimes/js/src/relative-path.js 478 B 49ms
├── ../../runtimes/js/src/bundle-url.js 447 B 50ms
├── ../../runtimes/js/src/loaders/browser/js-loader.js 407 B 45ms
├── ../../runtimes/js/src/cacheLoader.js 282 B 9ms
├── ../../runtimes/js/src/bundle-manifest.js 246 B 39ms
└── src/index.js 85 B 1.95s
dist/browser/split.0112a5d5.js 1.61 KB 973ms
├── Code from unknown sourcefiles 1.14 KB 0ms
├── ../../runtimes/js/src/get-worker-url.js 221 B 51ms
├── ../../runtimes/js/src/JSRuntime.js 157 B 23ms
└── src/split.js 105 B 36ms
# ^^ LODASH NOT INCLUDED
dist/browser/worker.f5b2ae32.js 1.38 KB 974ms
└── src/worker.js 19 B 378ms
# ^^ LODASH NOT INCLUDED
dist/browser/index.html 223 B 972ms
└── index.html 228 B 1.82s
Done in 8.79s.
If you look in the worker.[hash].js and split.[hash].js files, they point
to lodash but don't actually include it, triggering an error Cannot find module on page load.
💁 Possible Solution
We fixed this by monkey-patching the DefaultBundler by commenting out these lines.
🔦 Context
We gate a ton of functionality behind splits + web workers because our web application is pretty complex. It appears that few users do this, so I imagine this is not covered by your tests.
🐛 bug report
Using the latest versions of Parcel 2, dependencies are incorrectly excluded from code split bundles and Worker bundles that are descendants of that code split when scope hoisting is disabled. This triggers a
Cannot find module '[id]'
on page load on sites built with theparcel build
command.Scope hoisting is still really buggy for us and we haven't been able to debug that, so it's disabled. I'll likely submit a separate issue for that.
🎛 Configuration (.babelrc, package.json, cli command)
Take a look at this repository: https://github.com/embarktrucks/parcel-split-webworker-issue
🤔 Expected Behavior
Parcel should include pertinent dependencies in split bundles and Worker bundles that descend from those.
😯 Current Behavior
A bunch of dependencies are excluded.
To try this out, copy this repository into your
parcel/
repository atpackages/examples/
,cd
into the directory, and run:You will get output similar to this:
If you look in the
worker.[hash].js
andsplit.[hash].js
files, they pointto
lodash
but don't actually include it, triggering an errorCannot find module
on page load.💁 Possible Solution
We fixed this by monkey-patching the
DefaultBundler
by commenting out these lines.🔦 Context
We gate a ton of functionality behind splits + web workers because our web application is pretty complex. It appears that few users do this, so I imagine this is not covered by your tests.
💻 Code Sample
https://github.com/embarktrucks/parcel-split-webworker-issue
🌍 Your Environment
master
commitThe text was updated successfully, but these errors were encountered: