Conversation
91182ce to
9d9764b
Compare
lib/relative-module-paths.js
Outdated
| } | ||
|
|
||
| function resolveRelativeModulePath(name, child) { | ||
| name = name.replace(/\.js$/, ''); |
There was a problem hiding this comment.
this is needed because @babel/runtime is a "type": "commonjs" package that uses extensions -- which node supports but broccoli does not.
There was a problem hiding this comment.
babel 8 is ESM only, so I don't know if it would be compatible with broccoli -- maybe more hacks needed
There was a problem hiding this comment.
the latest broccoli only supports node 20.19 because it relies on require(esm). We're at the point where we can start doing the same in the wider ecosystem. This might be worth discussing at the next tooling team meeting
Also there is nothing stopping cjs from supporting extensions 🤔 what is the specific error here that the change is trying to fix?
There was a problem hiding this comment.
here is what the failure looks like: #531
There was a problem hiding this comment.
js is already a default extension
https://github.com/tleunen/babel-plugin-module-resolver/blob/master/src/normalizeOptions.js#L11
I'll debug it, but this makes me despair lol
There was a problem hiding this comment.
no, thee fix does not go in babel-plugin-module-resolver.
we override resolving logic with the function I changed -- so this is our own doing, and our own fix.
There is this: https://npmx.dev/package/amd-name-resolver which I also think is the wrong place to the fix.
The only place I think a deeper fix makes sense is loader.js.
or we lean in to composition, and because we have this need to eliminate extensions (and we don't want to encourage the broader ecosystem to use AMD), we just fix it here in ember-cli-babel.
The whole of moduleResolve could probably go away tho... because we have require resolve, and the URL utils.
but that feels like a bigger effort for another PR, rather than a dep-upgrade PR
There was a problem hiding this comment.
tl;dr: I think fixing in ember-cli-babel is correct
There was a problem hiding this comment.
especially since the alternative is to reach in to private code and call babel-plugin-module-resolver's own stripExtensions:
function stripExtension(modulePath, stripExtensions) {
let name = _path.default.basename(modulePath);
stripExtensions.some(extension => {
if (name.endsWith(extension)) {
name = name.slice(0, name.length - extension.length);
return true;
}
return false;
});
return name;
}which is about as safe as what I have in this PR -- albeit likely slower
There was a problem hiding this comment.
I did PR this to the upgrade branch tho: #532
|
From tooling team discussion: A more targeted fix is possible here: Line 271 in bdb4bd1 because the contents of |
|
what do you mean? what is there to configure/rename with that code?
I don't understand what you mean |
@babel/*
babel-plugin-debug-macros --> skipped to v2 -- in range for current support