-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exports in non-library entry files produces stray import identifiers #7781
Comments
My guess is that this has something to do with tree shaking/optimization that is removing unused code - since index.mjs doesn't actually do anything other than |
Yeah, it's likely something to do with tree shaking. As for "something that actually executes code", could you give a specific example? Here's what I tried: // index.mjs
export * from './module/core.mjs';
import * as core from './module/core.mjs';
console.log(core)
export default core Results in console.log($36f04a8a63fb858c$import$5ecbb526cd5c0bbc);$36f04a8a63fb858c$import$5ecbb526cd5c0bbc;
//# sourceMappingURL=index.7cbd2617.js.map Which still exhibits the error |
The current head of v2 (c9264c4) exhibits this problem on a fresh build |
Interestingly, running var $771420b136e5cd5f$export$2e2bcd8739ae039 = {
};
var $85d5af804b8f24f8$export$2e2bcd8739ae039 = $85d5af804b8f24f8$import$5ecbb526cd5c0bbc;
//# sourceMappingURL=index.ee61046f.js.map Which is different but still invalid |
Hey! Temporary but interesting fix. Running |
I had the same problem when running code from https://github.com/tensorflow/tfjs-examples/tree/master/lstm-text-generation. Can be resolved by using |
@mischnic I had the same issue when trying out react-vega (which depends on vega-embed). It's not clear from the above discussion whether it's a parcel bug (i.e., the importing behavior is static yet scope hoisting fails to understand that), or whether it's the library (fast-json-patch) having coding patterns that are not friendly to scope hoisting. |
I was able to build an application including
Related issue: adobe/react-spectrum-charts#346 |
🐛 bug report
I came across an issue where
parcel build
produces invalid code whenparcel
alone simply works.Say I have the following files:
If I run
parcel ./index.html
, it displays a blank website without any errors. However, if I runparcel build ./index.html
, the resulting built js file just looks like this:Which obviously, when run inside a browser, gives an undefined reference error for this strangely named variable that was never declared.
🎛 Configuration (.babelrc, package.json, cli command)
I have a reproduction repo here: https://github.com/Hazelfire/parcel-module-repro.
🤔 Expected Behavior
I expected the above code to compile correctly, and not create arcanely named variables. Especially considering that
yarn
without theyarn build
works fine.😯 Current Behavior
yarn build
produces invalid code as above💁 Possible Solution
Not sure what's causing this.
🔦 Context
The package fast-json-patch has a piece of code that matches this pattern, and therefore doesn't compile under
parcel build
. This is a dependency of vega-embed, which I'm using in my project. All projects dependent on fast-json-patch cannot be built usingparcel build
💻 Code Sample
https://github.com/Hazelfire/parcel-module-repro
🌍 Your Environment
The text was updated successfully, but these errors were encountered: