Open babel-bot opened 7 years ago
Any preferences for what this should desugar to in a babel world? A possible default implementation would just create an empty Object.create(null)
object per module. I assume that anything else would be making too many assumptions (outside of webpack doing its own thing).
I believe ModuleRecords should be frozen as well as being null objects.
The import.meta
object is an arbitrary object associated with a module, not the module record itself. The only thing the spec requires is that it was created as an ordinary object with null-prototype. The host may choose to freeze it but it's not required.
See also "Will this be locked down": https://github.com/tc39/proposal-import-meta#will-this-object-be-locked-down-in-any-way
Since it's left up to the implementation, my opinion is that Babel should freeze it until either the spec is finalized or we discover a reason it can't be for Babel's purposes. We'll see what other implementations want to do and what the committee finally accepts.
The spec is finalized; it won't be locked down.
Regarding the transform:
Not sure, maybe webpack should handle? Or in node?
We're in need of a simple transform to replace import.meta with an object that has a url
property based on the file's location on disk. When we have something I can ping this issue again to see if it'd be useful enough for other people to contribute.
Original issue submitted by @hzoo in https://github.com/babel/babel/issues/5832
Original issue submitted by @hzoo in https://github.com/babel/babylon/issues/539
Info
Proposed at TC39 Meeting: May 2017 Spec Repo: https://github.com/tc39/proposal-import-meta Spec Text: https://tc39.github.io/proposal-import-meta/ Moved to Stage 3 at the Sept 2017 meeting
Example
Parsing
Transform