forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the C++ callback that is required to configure the `import.meta` object and add one property: - url: absolute URL of the module PR-URL: nodejs#18368 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
- Loading branch information
Showing
9 changed files
with
112 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
const { | ||
setInitializeImportMetaObjectCallback | ||
} = internalBinding('module_wrap'); | ||
|
||
function initializeImportMetaObject(wrap, meta) { | ||
meta.url = wrap.url; | ||
} | ||
|
||
function setupModules() { | ||
setInitializeImportMetaObjectCallback(initializeImportMetaObject); | ||
} | ||
|
||
module.exports = { | ||
setup: setupModules | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Flags: --experimental-modules | ||
|
||
import '../common'; | ||
import assert from 'assert'; | ||
|
||
assert.strictEqual(Object.getPrototypeOf(import.meta), null); | ||
|
||
const keys = ['url']; | ||
assert.deepStrictEqual(Reflect.ownKeys(import.meta), keys); | ||
|
||
const descriptors = Object.getOwnPropertyDescriptors(import.meta); | ||
for (const descriptor of Object.values(descriptors)) { | ||
delete descriptor.value; // Values are verified below. | ||
assert.deepStrictEqual(descriptor, { | ||
enumerable: true, | ||
writable: true, | ||
configurable: true | ||
}); | ||
} | ||
|
||
const urlReg = /^file:\/\/\/.*\/test\/es-module\/test-esm-import-meta\.mjs$/; | ||
assert(import.meta.url.match(urlReg)); |