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
Simplify helper dependencies #15771
Simplify helper dependencies #15771
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/54843/ |
CI errors seem to be related? |
|
ff09744
to
3e1e170
Compare
When I tried to this in the past, I had problems with ESM and cycles. i.e. if you have these files: // @babel/core
export { x } from "@babel/helper-1";
export { y } from "@babel/helper-2"; // @babel/helper-1
import { y } from "@babel/core";
export let x = 1 + x; // @babel/helper-2
export let y = 2; it fails because |
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.
Note: I'm also exploring a fix that doesn't rely on the shape of the dependencies tree.
Releasing this, hoping to fix the regression. |
In this PR we simplify the helper dependencies by replacing imports from
@babel/types
,@babel/template
and@babel/traverse
to a peer dependent@babel/core
. It probably also fixes #15765 but we will need confirmation once the proposed changes are published.Possible story on #15765:
Given node_modules layouts as followed. Here dotted link means the start point has declared dependency on the end point, and solid link means the start point has a folder named the end point.
The
helper-replace-supers
callstraverse.visitors.merge
from@babel/traverse
to merge the environment visitor with a visitor hooking on theScopeable
alias .babel/packages/babel-helper-replace-supers/src/index.ts
Lines 80 to 93 in 30ff3ac
After #15702 is merged in
@babel/traverse@7.22.8
,visitors.merge
will explode the alias into node types. HereScopeable
is expanded toClassAccessorProperty
and other AST nodes according to the latest@babel/types
definition. At this time the visitor is not executed.Now when the visitor is eventually invoked by
ember-cli-babel
, the root@babel/traverse
is backed by an older version of@babel/types
, which does not recognizeClassAccessorProperty
and therefore an error is thrown.So in this PR we replace all traverse usage with peer dependencies of
@babel/core
. It should at least alleviate the situation of duplicated libraries.For end users, the best solution is still to deduplicate
@babel/types
instances in node_modules: It is more memory efficient and less prone to compatibility issues like this.