If you're using code splitting and then two different chunks attempt to reference the same static file (e.g. an image). One of the chunks will get a client-side runtime error when attempting to require that static file Cannot find module './path/to/shared/static/file'.
Unconfigured, yarn add -D parcel@next && yarn parcel index.html, see example repo
No requires throw an error in either bundle
The require in both bundles throws an error.
This has popped up a number of times in lighthouse-ci, but I finally found the minimal repro of it.
There's a nearly identical issue but it's claimed to be fixed in parcel 2 already, so perhaps this is slightly different?
https://github.com/parcel-bundler/parcel/issues/112 https://github.com/parcel-bundler/parcel/issues/112#issuecomment-562856846
Similarish issues that still seemed slightly different to me
https://github.com/parcel-bundler/parcel/issues/3442 (possibly?)
https://github.com/parcel-bundler/parcel/issues/2515 (unresolved and unsubstantiated, maybe some of those are related?)
entry.js
setTimeout(() => import('./module.a.js'), 1000)
setTimeout(() => import('./module.b.js'), 0)
module-a.js
console.log('A says', require('./logo.svg'))
module-b.js
import './module-a.js'
console.log('B says', require('./logo.svg'))
In this example B is importing A directly for simplicity but the same issue occurs if there is a shared file C.
See https://github.com/patrickhulce/parcel-bug-code-splitting
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.12.4 and 2.0.0-alpha.3.2 both affected |
| Node | v10.15.3
| npm/Yarn | N/A
| Operating System | macOS |
Having the exact same issue in parcel 1.12.3, the description is spot-on. Is there any workaround for this at the moment, apart from _not_ using code-splitting .. ?
Codesplitting works for me, BUT only in build. The dev server page throws:
Cannot find module '../node_modules/parcel-bundler/src/builtins/bundle-url.js'
Most helpful comment
Having the exact same issue in parcel
1.12.3, the description is spot-on. Is there any workaround for this at the moment, apart from _not_ using code-splitting .. ?