`url:` imports fail with `Could not resolve bundle with id`
See original GitHub issue🐛 bug report
It seems like https://github.com/parcel-bundler/parcel/issues/4365 has risen from the dead.
When having a <script>
tag with type="module"
which imports something which lazily imports something which imports something using the url:
scheme, running the code results in a runtime error.
🎛 Configuration (.babelrc, package.json, cli command)
package.json:
{
"scripts": {
"build": "parcel build src/index.html",
"serve": "parcel serve src/index.html"
},
"dependencies": {
"@parcel/babel-plugin-transform-runtime": "nightly",
"@parcel/babel-preset-env": "nightly",
"@parcel/bundler-default": "nightly",
"@parcel/compressor-raw": "nightly",
"@parcel/config-default": "nightly",
"@parcel/core": "nightly",
"@parcel/css": "latest",
"@parcel/fs": "nightly",
"@parcel/namer-default": "nightly",
"@parcel/optimizer-css": "nightly",
"@parcel/optimizer-cssnano": "nightly",
"@parcel/optimizer-htmlnano": "nightly",
"@parcel/optimizer-terser": "nightly",
"@parcel/packager-css": "nightly",
"@parcel/packager-html": "nightly",
"@parcel/packager-js": "nightly",
"@parcel/packager-raw-url": "nightly",
"@parcel/resolver-default": "nightly",
"@parcel/runtime-browser-hmr": "nightly",
"@parcel/runtime-js": "nightly",
"@parcel/runtime-react-refresh": "nightly",
"@parcel/runtime-service-worker": "nightly",
"@parcel/transformer-babel": "nightly",
"@parcel/transformer-css": "nightly",
"@parcel/transformer-css-experimental": "nightly",
"@parcel/transformer-html": "nightly",
"@parcel/transformer-inline-string": "nightly",
"@parcel/transformer-js": "nightly",
"@parcel/transformer-postcss": "nightly",
"@parcel/transformer-posthtml": "nightly",
"@parcel/transformer-react-refresh-wrap": "nightly",
"@parcel/transformer-sass": "nightly",
"@parcel/transformer-webmanifest": "nightly",
"@parcel/utils": "nightly",
"parcel": "nightly"
}
}
cli command: yarn install && yarn build && http-server -p 1234 dist/
🤔 Expected Behavior
The URL to the SVG should be logged to the console.
😯 Current Behavior
lazy.e20bce0f.js:1 Uncaught (in promise) Error: Could not resolve bundle with id 2vcPw
at Object.r (lazy.e20bce0f.js:1:666)
at Object.<anonymous> (lazy.e20bce0f.js:1:487)
at o ((index):1:416)
at Object.<anonymous> (lazy.e20bce0f.js:1:378)
at o ((index):1:416)
at (index):1:673
at async (index):1:716
💁 Possible Solution
Fix so that it no longer throws but instead correctly gives the URL of the SVG.
Alternatively, please fix https://github.com/parcel-bundler/parcel/issues/5683 which forced me to use a <script>
tag instead of <script src="
and triggered this error.
🔦 Context
Was happily on parcel 2.0.1. Then my colleague wanted to import a style sheet per module on our react project. Reason being readability and that unused CSS doesn’t load too early.
It worked out of the box (like parcel usually does) 😋 but the precedence was wrong.
When doing
in entrypoint:
import "./low-precedence.scss"; // general styling
import "./script.ts";
in script.ts:
import "./high-precedence.scss";
The output bundle first contained high-precedence and then low-precedence, making it impossible to override general styling without making every selector more specific.
I was about to report an issue but then I discovered https://github.com/parcel-bundler/parcel-css, which fixed all issues and made the scss build time much faster 🎉
Buuutt to install that I had to update to the latest parcel, where I was greeted with https://github.com/parcel-bundler/parcel/issues/5683.
After figuring out the workaround I thought I could finally be happy but then this happened 😔
💻 Code Sample
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | 2.0.0-nightly.984+74fcc3fb |
Node | v17.4.0 |
npm/Yarn | 3.1.1 |
Operating System | macOS 12.1 (21C52) |
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:16 (1 by maintainers)
Top GitHub Comments
Hey, I am also struggling with this issue. I am on Parcel v2.2.1.
In my case it only happens in production build when loading the page. The parcel build process itself works. I already tried to:
Scope hoisting is one of the reasons I’m using parcel because not having it increases bundle size so unfortunately that’s not an option for me 😦