generated from tc39/template-for-proposals
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Layer 0: Replace importMeta
object with importMetaHook
function
#77
Comments
Few clarifications needed:
|
|
I'm fine with this proposal. |
caridy
added a commit
that referenced
this issue
Sep 23, 2022
fixes #77: importMetaHook and handler for options bag
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ECMA-262 exposes two host hooks to initialize
import.meta
: HostGetImportMetaProperties and HostFinalizeImportMeta.HostGetImportMetaProperties
doesn't receives any parameter and returns a list of properties, that ECMA-262 will copy on theimport.meta
objectHostFinalizeImportMeta
receives theimport.meta
object, and can modify it as it wantsThe second host hook is enough to cover all the use cases of the first hook, but not the other way around.
This proposal currently implements
HostGetImportMetaProperties
: theimportMeta
parameter of theModule
constructor is equivalent to the list of properties returned by the hook. However, this is not enough to replicate the behavior of the various hosts:import.meta
object (source: "XS is freezing import.meta today" in https://github.com/tc39/notes/blob/167155eeb708d84e1758d99c88b15670f9b81f75/meetings/2020-03/march-31.md#importmeta-for-stage-4)import.meta
(source: runconsole.log(Object.getPrototypeOf(import.meta));
in Bun)With
importMetaHook
, both behaviors would be possible:This has the same serializability implications of
importHook
: modules with a non-defaultimportMetaHook
would not be serializable.The text was updated successfully, but these errors were encountered: