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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: @babel/transform-export-namespace-from is not included after v7.23.3 #16155
Comments
Hey @BrooklynKing! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly. If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite. |
The change is expected, according to our compat data babel/packages/babel-compat-data/data/plugins.json Lines 749 to 762 in 380d186
The namespace export has been supported natively since Node.js 13.2. So this plugin is not enabled giving Node.js 14 as a target. Previously this procedure is only applied when modules is false . After 7.23.3, it is applied to other modules options except auto , which uses the caller support data instead of the compat data.
Is this change breaking your website? |
Correct me if I'm wrong, but according to current codebase, this plugin is applied only if In our case after we upgraded to |
If you specify Thanks for digging the codebase, babel/packages/babel-preset-env/src/index.ts Lines 397 to 408 in 380d186
specifies the only exception case where we should load In Babel 7.23.3, the babel/packages/babel-helper-compilation-targets/src/filter-items.ts Lines 76 to 104 in 380d186
which goes through the We consider this change a patch because |
Thank you for explanation. So if it's expected that for node >13.1 I should explicitly add that plugin if I'm not using |
Actually quite the opposite, Node >= 13.2 already supports If you want to force enabling this plugin, please specify the {
"presets": [["@babel/preset-env", { "include": ["transform-export-namespace-from"] }]]
} So you don't have to rely on the |
Yeah, thanks again for the explanation, I think now I understand better in what part of our flow we don't have a proper sequence. I will close issue. |
@JLHwung Your suggestion of force-including the plugin works in my case too, though I kind of expected it to work without having to do that. |
Babel parses Do you have a complete stack trace for the error you are seeing? |
The stack trace is: mareolan@LAPTOP:~/tmp/tst-babel$ ./node_modules/.bin/babel src --out-dir lib
SyntaxError: /home/mareolan/tmp/tst-babel/src/index.js: Export namespace should be first transformed by `@babel/plugin-transform-export-namespace-from`.
> 1 | export * as Extra from "./extra.js";
| ^^^^^^^^^^
2 |
at File.buildCodeFrameError (/home/mareolan/tmp/tst-babel/node_modules/@babel/core/lib/transformation/file/file.js:205:12)
at NodePath.buildCodeFrameError (/home/mareolan/tmp/tst-babel/node_modules/@babel/traverse/lib/path/index.js:98:21)
at assertExportSpecifier (/home/mareolan/tmp/tst-babel/node_modules/@babel/helper-module-transforms/lib/normalize-and-load-metadata.js:98:16)
at /home/mareolan/tmp/tst-babel/node_modules/@babel/helper-module-transforms/lib/normalize-and-load-metadata.js:191:9
at Array.forEach (<anonymous>)
at /home/mareolan/tmp/tst-babel/node_modules/@babel/helper-module-transforms/lib/normalize-and-load-metadata.js:190:31
at Array.forEach (<anonymous>)
at getModuleMetadata (/home/mareolan/tmp/tst-babel/node_modules/@babel/helper-module-transforms/lib/normalize-and-load-metadata.js:137:27)
at normalizeModuleAndLoadMetadata (/home/mareolan/tmp/tst-babel/node_modules/@babel/helper-module-transforms/lib/normalize-and-load-metadata.js:47:7)
at rewriteModuleStatementsAndPrepareHeader (/home/mareolan/tmp/tst-babel/node_modules/@babel/helper-module-transforms/lib/index.js:92:54) {
code: 'BABEL_TRANSFORM_ERROR'
} It can be simulated by creating simple project in an empty folder: npm init -y
npm i -D @babel/core @babel/cli @babel/preset-env
mkdir src
echo 'export * as Extra from "./extra.js";' > src/index.js
echo 'export const A = 10;' > src/extra.js
cat > babel.config.js <<EOF
module.exports = {
sourceType: "unambiguous",
presets: [
[
"@babel/preset-env",
{
modules: "commonjs",
targets: "node 16",
bugfixes: true,
},
],
],
};
EOF And then just run ./node_modules/.bin/babel src --out-dir lib There seems to be an issue with Adding |
@mareolan Thanks for the reproduction, reopen the issue. |
馃捇
How are you using Babel?
Programmatic API (
babel.transform
,babel.parse
)Input code
Babel v7.23.2 - Link
Babel v7.23.5 - Link
Configuration file name
No response
Configuration
No response
Current and expected behavior
After
7.23.3
version plugintransform-export-namespace-from
is not included in config, provided by@babel/preset-env
.I belive it's because of changes in #15988
Explicitly this line
before that plugin included if
module !== "auto"
, but now it requiremodule === "auto"
to be included. Looks like a typo, since other part of that condition are changes properly (api.caller?.(supportsExportNamespaceFrom)
into!api.caller(supportsExportNamespaceFrom)
)Environment
Babel REPL
Possible solution
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: