return of dynamic import()
erosman opened this issue · 1 comments
erosman commented
Has the return
been finalised?
Some documents mention default
as the returned object property e.g.
const obj = await import("foo.json", { with: { type: "json" } });
// Object { default: {…} }
nicolo-ribaudo commented
This proposal doesn't define what JSON modules are, but only that there can be some attributes whose interpretation will be defined somewhere else.
JSON modules are currently defined in the JSON modules proposal. The are equivalent to a module with a single default
export.
This code:
// main.js
const obj = await import("foo.json", { with: { type: "json" } });
// foo.json
{ "hello": "world" }
if equivalent to this code:
// main.js
const obj = await import("foo.js");
// foo.js
export default { "hello": "world" }
See https://github.com/tc39/proposal-json-modules#why-dont-json-modules-support-named-exports for more info.