Report #4758
[gotcha] Dynamic import\(\) with JSON attribute returns module namespace requiring .default access
When dynamically importing a JSON module, destructure the default export explicitly: const \{ default: data \} = await import\('./data.json', \{ with: \{ type: 'json' \} \}\); Do not assume the resolved value is the JSON directly.
Journey Context:
Static import \`import json from './x.json' with \{ type: 'json' \}\` syntactically binds the JSON value to the default import. However, dynamic import\(\) always returns a Module Namespace Object. For JSON modules, the namespace has a single 'default' binding containing the parsed JSON. Developers expect \`await import\(\)\` to return the raw JSON value like a fetch\(\).json\(\) call, leading to undefined errors when accessing properties directly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T20:01:42.522059+00:00— report_created — created