-
-
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
Parcel reports "Export 'X' is not defined" if a ESM module tries to export a function
#2820
Comments
Got the same thing with |
Also got the same thing with |
Same issue here:
|
I lock these package version parcel used, @babel/*** < 7.4.0. Now resolve this problem.
|
I use typescript, no babel in project, but it hurts my current build with mobx-react :( |
Following the lead from @Zero2key, the babel parser seems to be the culprit and just doing this package gets our builds working for now (as a workaround until a fix is introduced): |
Confirmed that adding just the following to
|
@mweststrate confirm it HELPS ME A LOT!!! |
There is no matching babel issue open, correct? (which isn't strange since 7.4.0 was only released yesterday). |
Maintainers: does this mean a new issue should be opened on babel? Or is it an API compatibility issue with the latest babel version? |
I find this @babel/parser PR Allow any reserved word in |
It triggered by this line in Parcel. Setting parcel/packages/core/parcel-bundler/src/assets/JSAsset.js Lines 56 to 64 in 32f3327
Reproduction using only Babel: const parser = require("@babel/parser");
const code = `
function original(value) {
if (value) {
return value.base;
}
}
export { original };
`;
console.log(parser.parse(code, {
strictMode: false, // <-------------------- works with `true` or `null`
sourceType: 'module',
})); So I guess it's a Babel bug? |
Just released parcel v1.12.3 which downgrades Babel to <7.4 while we figure this out. |
Filed this issue with babel: babel/babel#9720 |
Fixed in Babel 7.4.2 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. |
🐛 bug report
If in an ESM module the
export
statement refers to a function, this consistently fails the build.🎛 Configuration (.babelrc, package.json, cli command)
To reproduce, clone: https://github.com/mweststrate/parcel-bug,
yarn install
,yarn build
This happens with an out-of-the-box configuration with parcel, no
.babelrc
, package.json:🤔 Expected Behavior
The project should build without error, even when an
export
statement references a function😯 Current Behavior
Build failure, any referred function is reported as
Export '...' is not defined
When using the
immer
package with parcel I consistently get the following build error:The package does bundle correctly when
original
,isDraft
andisDraftable
are removed from the export statement. Unlike all other exports, which are defined asvar
, these three are defined asfunction
s in the module scope innode_modules/immer/dist/immer.module.js
, like:💁 Possible Solution
🔦 Context
I'm converting a CRA app to parcel, however this is withholding me from that.
💻 Code Sample
https://github.com/mweststrate/parcel-bug
🌍 Your Environment
Linux x250 4.18.0-15-generic #16-Ubuntu SMP Thu Feb 7 10:56:39 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: