Skip to content

refactor(ESM): convert babel-eslint-plugin and babel-register#17943

Merged
JLHwung merged 6 commits into
babel:mainfrom
JLHwung:convert-esm
Apr 22, 2026
Merged

refactor(ESM): convert babel-eslint-plugin and babel-register#17943
JLHwung merged 6 commits into
babel:mainfrom
JLHwung:convert-esm

Conversation

@JLHwung

@JLHwung JLHwung commented Apr 21, 2026

Copy link
Copy Markdown
Contributor
Q                       A
Fixed Issues? Convert babel-eslint-plugin and babel-register to ESM
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link babel/website#3194
Any Dependency Changes?
License MIT

In this PR we converted babel-eslint-plugin and babel-register to ESM, thanks to the require(esm) supported in Node.js.

Only one failing babel-register test is disabled, see comments below.

@babel-bot

babel-bot commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/61331

Comment thread packages/babel-register/test/index.js Outdated
});

test("installs source map support when requested", () => {
test.skip("installs source map support when requested", () => {

@JLHwung JLHwung Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This test is failing because the teardown step delete require.cache[registerFile]; no longer work for ESM, therefore any subsequent test becomes reentry to the index file and thus the installSourceMapSupport is always a no-op after it is installed:

function installSourceMapSupport() {
// @ts-expect-error assign to function
installSourceMapSupport = () => {};
sourceMapSupport.install({
handleUncaughtExceptions: false,
environment: "node",
// @ts-expect-error FIXME: url can be null?
retrieveSourceMap(filename: string) {
const map = maps?.[filename];
if (map) {
return { url: null, map: map };
} else {
return null;
}
},
});
}

This issue will be fixed by #17941.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Update: After #17941 was merged, I have interactively rebased on main and removed the test skip commit 2bb8379.

@JLHwung JLHwung mentioned this pull request Apr 21, 2026
@pkg-pr-new

pkg-pr-new Bot commented Apr 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: 327f51e

const ruleComposer = require("../rule-composer.cjs");
const rule = require("eslint/use-at-your-own-risk").builtinRules.get("new-cap");
import * as ruleComposer from "../rule-composer.js";
// eslint-disable-next-line import/no-unresolved

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Disabled due to an upstream issue: import-js/eslint-plugin-import#1810.

@JLHwung
JLHwung merged commit 90cf79b into babel:main Apr 22, 2026
55 of 56 checks passed
@JLHwung
JLHwung deleted the convert-esm branch April 22, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants