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
Do not add .js
extension to injected helper imports when module transform presents
#10833
Conversation
"@babel/plugin-transform-modules-*", | ||
); | ||
// Remove the trailing `.js` requires by ES Module when module transforms presents | ||
const validSource = moduleTransforms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically only amd
and umd
are affected by this issue since by default RequireJS does not support resolving foo.js => foo.js
as-is out of the box. You may configure to support this but we did cause breaking changes to these users.
Both CommonJS and SystemJS support foo.js => foo.js
, but at the same time they also support foo => foo.js
. Hence I remove .js
for the sake of briefness. C.f. #10549 (review)
@@ -1,5 +1,6 @@ | |||
import foo from "foo"; | |||
|
|||
class Example { | |||
method() {} | |||
property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrite this test case since it looks more practical that an ESM supported environment does not support class-properties and so we need to transform.
.js
extension to injected helper imports when module transforms presents..js
extension to injected helper imports when module transform presents.
.js
extension to injected helper imports when module transform presents..js
extension to injected helper imports when module transform presents
This should not apply to systemjs transform, or be configurable. Systemjs is an es module compliant polyfill. We use this in https://www.npmjs.com/package/es-dev-server where we use es modules in the browser during development and fallback to systemjs if modules are not supported. |
@babel/core-team What do you think about reverting the PR which introduced the regression, releasing it before Monday and then re-introducing the
Note that the es modules specification doesn't say anything about file extension. The |
Indeed! More, the spec is intentionally silent on how a string is to be resolved. A given module loader (browser, Node, etc.) may choose to implement its own rules for the string parse. It is required to be a string literal, but that is the only thing specified about the module specifier. |
@LarsDenBakker This PR restores to behaviour for SystemJS to pre 7.7.5 so it should work. I discussed with @nicolo-ribaudo a bit and we are now reverting #10549 for 7.7.6. This PR is thus closed. A new option We are planing to change its default to |
Makes sense guys, thanks! |
As a follow up to #10549, this PR partially reverts the recently introduced behaviour on the helper imports. It will remove
.js
added in #10549 when other module transforms presents.The
.js
extension is only required by native ES Modules and we can safely remove it when it will be transformed to other module formats.Compatibility Note:
When using transform-runtime 7.7.6 with
it will still add the
.js
extension to imports due to lack of context variables. This will cause trouble to AMD users. If you are experience this issue, please upgrade these plugins to 7.7.6.