GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(json, text, bytes modules): keep both default and namespace imports by JLHwung · Pull Request #18648 · babel/babel

Conversation

@JLHwung

@JLHwung JLHwung commented Nov 17, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
Q                       A
Fixed Issues? proposal-x-modules remove the default binding when transforming import value, * as ns from "./x.json" with { type: "json" }
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
Need backport? 7.x
License MIT

In this PR we fix an issue reported by Claude Fable 5.2: Given the input

import value, * as ns from "./x.json" with { type: "json" };
use(value, ns);

The JSON module transform generates the output

const ns = {
  default: JSON.parse(_readFileSync(new URL(import.meta.resolve("./x.json"))))
};
use(value, ns);   // value is never declared

which will compile successfully but will throw a runtime error: "value is never declared".

The fix is to record the default and namespace identifier separately and add const ns = { default: value } right after the injected declaration.

The REPL reproduction is not available due to #18643.

Assisted-by: Claude Fable 5.2

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@JLHwung
JLHwung added this pull request to stack #18587 November 17, 2026 15:19
@JLHwung JLHwung added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Nov 17, 2026
@babel-bot

babel-bot commented Nov 17, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pkg-pr-new

pkg-pr-new Bot commented Nov 17, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Open in StackBlitz

commit: 46d6a37

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@liuxingbaoyu

liuxingbaoyu commented Nov 17, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

The REPL is actually working, it’s just not displaying correctly. :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JLHwung

JLHwung commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

The REPL is actually working, it’s just not displaying correctly. :)

OK, to clarify, what I mean here is that I can not reproduce this issue on REPL using proposal-bytes-module following these steps:

  • Open https://babeljs.io/repl/build/63398
  • Add External plugin
  • Search and choose "proposal-bytes-module"

Expected: REPL should load proposal-bytes-module
Actual: It throws an error and fail to load the plugin, because as an official babel plugin, it is not included in the standalone build.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Base automatically changed from jlhwung/fix-regenerator-using-declaration to main November 17, 2026 22:48
@JLHwung
fix(json, text, bytes modules): keep both default and namespace imports
46d6a37
`import value, * as ns from "./x.json" with { type: "json" }` only
declared the last specifier, so `value` was left as a reference to an
undeclared variable. Both bindings are now declared.

Assisted-by: Claude Fable 5.2
@JLHwung
JLHwung force-pushed the jlhwung/fix-x-modules-default-and-namespace branch from 8c7e02b to 46d6a37 Compare November 17, 2026 22:48
nicolo-ribaudo
nicolo-ribaudo approved these changes Nov 18, 2026
View reviewed changes
@JLHwung
JLHwung added this pull request to the merge queue Nov 19, 2026
@JLHwung JLHwung added the 7.x: needs backport label Nov 19, 2026
Merged via the queue into main with commit 7314a28 Nov 19, 2026
46 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@JLHwung
JLHwung deleted the jlhwung/fix-x-modules-default-and-namespace branch November 19, 2026 23:16
@babel-bot babel-bot mentioned this pull request Nov 19, 2026
fix(json, text, bytes modules): keep both default and namespace imports #18668
Merged
@babel-bot

babel-bot commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Backported to 7.x in #18668.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@babel-bot babel-bot removed the 7.x: needs backport label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@nicolo-ribaudo nicolo-ribaudo nicolo-ribaudo approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

PR: Bug Fix 🐛 A type of pull request used for our changelog categories

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@JLHwung @babel-bot @liuxingbaoyu @nicolo-ribaudo
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.