10BC0 build(Babel 8): disable JSON module transform by JLHwung · Pull Request #17468 · babel/babel · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@JLHwung
Copy link
Contributor
@JLHwung JLHwung commented Aug 5, 2025
Q                       A
Fixed Issues? Fixes #17466
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Babel 8 requires Node.js 20.19.0+ featured native JSON modules support, so we can skip the JSON transform, which would otherwise generates codes relying on Node.js internals.

In this PR, the rollup is configured such that the JSON module import is untouched, here is a comparison of the first 10 lines of babel-traverse/lib/index.js between 8.0.0-beta.1 and this PR

8.0.0-beta.1

import buildDebug from 'debug';
import { codeFrameColumns } from '@babel/code-frame';
import * as _t from '@babel/types';
import { parse } from '@babel/parser';
import { createRequire } from 'module';
import generator from '@babel/generator';
import template from '@babel/template';

const ReferencedIdentifier = ["Identifier", "JSXIdentifier"];
const ReferencedMemberExpression = ["MemberExpression"];

This PR

import buildDebug from 'debug';
import { codeFrameColumns } from '@babel/code-frame';
import * as _t from '@babel/types';
import { parse } from '@babel/parser';
import globalsBuiltinLower from '@babel/helper-globals/data/builtin-lower.json' with { type: 'json' };
import globalsBuiltinUpper from '@babel/helper-globals/data/builtin-upper.json' with { type: 'json' };
import generator from '@babel/generator';
import template from '@babel/template';

const ReferencedIdentifier = ["Identifier", "JSXIdentifier"];

@JLHwung JLHwung added the PR: Internal (next major) 🏠 A type of pull request used for our changelog categories for next major release label Aug 5, 2025
@babel-bot
Copy link
Collaborator
babel-bot commented Aug 5, 2025

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

@pkg-pr-new
Copy link
pkg-pr-new bot commented Aug 5, 2025

Open in StackBlitz

commit: 24371af

@JLHwung JLHwung force-pushed the skip-json-modules-transform-for-babel-8 branch from 3ebcb19 to 24371af Compare August 6, 2025 14:48
@JLHwung JLHwung requested a review from nicolo-ribaudo August 6, 2025 15:17
esModule: true,
file: outputFile,
format,
importAttributesKey: "with",
Copy link
Member

Choose a reason for hiding this comment

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

Hopefully Rollup will switch to the correct default in the next major 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely.

@JLHwung JLHwung merged commit df114e9 into babel:main Aug 7, 2025
76 checks passed
@JLHwung JLHwung deleted the skip-json-modules-transform-for-babel-8 branch August 7, 2025 19:09
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Nov 7, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Internal (next major) 🏠 A type of pull request used for our changelog categories for next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@babel/traverse 8.0.0-beta.1 still include node, cani i use babel in browser with babel8?

4 participants

0