GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||
GeezerVison is showing github.com — fix(json, text, bytes modules): keep both default and namespace imports by JLHwung · Pull Request #18648 · babel/babel Conversation
|
| 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.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/63411 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
commit: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
The REPL is actually working, it’s just not displaying correctly. :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
OK, to clarify, what I mean here is that I can not reproduce this issue on REPL using
Expected: REPL should load |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
`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
8c7e02b to
46d6a37
Compare
There was an error while loading. Please reload this page.
|
Backported to 7.x in #18668. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.