Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import assertions #351

Open
legendecas opened this issue Mar 10, 2022 · 5 comments
Open

Import assertions #351

legendecas opened this issue Mar 10, 2022 · 5 comments

Comments

@legendecas
Copy link
Member

Prior to ShadowRealm, stage 3 proposal import assertions introduced a new parameter to the dynamic import call as:

import("foo.json", { assert: { type: "json" } });

Also notably, stage 1 proposal like https://github.com/tc39/proposal-import-reflection is trying to introduce new options to the second parameter of dynamic import call:

const x = await import("<specifier>", { as: "<reflection-type>" });

Should ShadowRealm.prototype.importValue support such features?

@ljharb
Copy link
Member

ljharb commented Mar 10, 2022

It must support import assertions, or you wouldn’t be able to import json from a fresh realm where nobody could have mutated it.

@littledan
Copy link
Member

littledan commented Jun 2, 2022

Yes, import assertions surely need to be threaded through here, although they will be quite useless at first. The absence from the current specification is purely historical, as import assertions were not yet Stage 3 when the Realm spec was written. IMO the third argument of importValue should be of the same form as the second argument of dynamic import (which should ensure forward compatibility with evaluator attributes, which seem to have new interest in committee).

@caridy
Copy link
Collaborator

caridy commented Jun 3, 2022

or you wouldn’t be able to import json from a fresh realm

You will not be able to do that @ljharb, it will throw because the object can't cross the callable boundary.

@ljharb
Copy link
Member

ljharb commented Jun 3, 2022

ha, good point

I’d still expect assertions to work in a general sense.

@littledan
Copy link
Member

I agree that these should be plumbed through. The difference is observable since some things will be errors rather than having that third argument ignored. Theoretically, import assertions might work in some "other" host environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants