Skip to content

Upgrade babel deps#530

Open
NullVoxPopuli wants to merge 2 commits intomasterfrom
nvp/upgrade-babel-runtime
Open

Upgrade babel deps#530
NullVoxPopuli wants to merge 2 commits intomasterfrom
nvp/upgrade-babel-runtime

Conversation

@NullVoxPopuli
Copy link
Contributor

@NullVoxPopuli NullVoxPopuli commented Feb 4, 2026

  • @babel/*

    • just some patches (and vuln fixes)
  • babel-plugin-debug-macros --> skipped to v2 -- in range for current support

    • drop babel < 7
    • drop node < 16

@NullVoxPopuli NullVoxPopuli changed the title Upgrade @babel/runtime Upgrade babel deps Feb 4, 2026
@NullVoxPopuli NullVoxPopuli force-pushed the nvp/upgrade-babel-runtime branch from 91182ce to 9d9764b Compare February 4, 2026 20:00
}

function resolveRelativeModulePath(name, child) {
name = name.replace(/\.js$/, '');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is needed because @babel/runtime is a "type": "commonjs" package that uses extensions -- which node supports but broccoli does not.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that still true for babel8?

Copy link
Contributor Author

@NullVoxPopuli NullVoxPopuli Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

babel 8 is ESM only, so I don't know if it would be compatible with broccoli -- maybe more hacks needed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is what the failure looks like: #531

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tl;dr: I think fixing in ember-cli-babel is correct

Copy link
Contributor Author

@NullVoxPopuli NullVoxPopuli Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did PR this to the upgrade branch tho: #532

@ef4
Copy link
Collaborator

ef4 commented Feb 10, 2026

From tooling team discussion:

A more targeted fix is possible here:

return new Funnel(transpiledHelpers, {

because the contents of @babel/runtime that end up in the AMD modules get there entirely because of that code. We can patch/adjust babel/runtime so that the imports and the defines line up correctly.

@NullVoxPopuli
Copy link
Contributor Author

NullVoxPopuli commented Feb 10, 2026

what do you mean? what is there to configure/rename with that code?

We can patch/adjust babel/runtime so that the imports and the defines line up correctly.

I don't understand what you mean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants