I got a problem in [email protected] when I import a module which contain index.mjs and index.js. For example [email protected] - check my example
-> % npm start
> parcel2-example-bug@ start /Users/vladislav/dev/example-svelte3
> parcel build src/index.html --no-cache --no-minify
ร External modules are not supported when building for browser
at Object.generateExternalImport (./node_modules/@parcel/scope-hoisting/lib/formats/global.js:37:9)
at exit (./node_modules/@parcel/scope-hoisting/lib/link.js:540:23)
at NodePath._call (./node_modules/@babel/traverse/lib/path/context.js:53:20)
at NodePath.call (./node_modules/@babel/traverse/lib/path/context.js:40:17)
at NodePath.visit (./node_modules/@babel/traverse/lib/path/context.js:97:8)
at TraversalContext.visitQueue (./node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitSingle (./node_modules/@babel/traverse/lib/context.js:90:19)
at TraversalContext.visit (./node_modules/@babel/traverse/lib/context.js:146:19)
at Function.traverse.node (./node_modules/@babel/traverse/lib/index.js:94:17)
at traverse (./node_modules/@babel/traverse/lib/index.js:76:12)
When I manualy remove index.mjs from svelte it works fine
I think this is rather related to the sub packages inside of svelte:
node_modules/svelte/
โโโ internal
โย ย โโโ index.mjs
โย ย โโโ package.json
โโโ package.json
โโโ store
โโโ index.mjs
โโโ package.json
I updated the issue and the example with fresh Parcel version.
The main/module/browser fields in package.json turn on library mode: node modules aren't bundled (as you would expect for a library...). It tried that in this case as well. But having imports to bare specifiers on a webpage wouldn't work, therefore the error.
To fix this:
diff --git package.json package.json
index 7570c2c..385ad5b 100644
--- package.json
+++ package.json
@@ -1,6 +1,5 @@
{
"name": "parcel2-example-bug",
- "browser": "dist/index.html",
"source": "src/index.html",
"private": true,
"scripts": {
Most helpful comment
I updated the issue and the example with fresh Parcel version.