| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 39fbce7 commit 5de37a1
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -130,6 +130,7 @@ class DefaultModuleLoader { | |||
| 130 | 130 | const { setCallbackForWrap } = require('internal/modules/esm/utils'); | |
| 131 | 131 | const module = new ModuleWrap(url, undefined, source, 0, 0); | |
| 132 | 132 | setCallbackForWrap(module, { | |
| 133 | + initializeImportMeta: (meta, wrap) => this.importMetaInitialize(meta, { url }), | ||
| 133 | 134 | importModuleDynamically: (specifier, { url }, importAssertions) => { | |
| 134 | 135 | return this.import(specifier, url, importAssertions); | |
| 135 | 136 | }, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,8 @@ | |||
| 1 | 1 | // Flags: --experimental-import-meta-resolve | |
| 2 | 2 | import '../common/index.mjs'; | |
| 3 | 3 | import assert from 'assert'; | |
| 4 | + import { spawn } from 'child_process'; | ||
| 5 | + import { execPath } from 'process'; | ||
| 4 | 6 | ||
| 5 | 7 | const dirname = import.meta.url.slice(0, import.meta.url.lastIndexOf('/') + 1); | |
| 6 | 8 | const fixtures = dirname.slice(0, dirname.lastIndexOf('/', dirname.length - 2) + 1) + 'fixtures/'; | |
@@ -30,3 +32,39 @@ assert.strictEqual( | |||
| 30 | 32 | ); | |
| 31 | 33 | assert.strictEqual(import.meta.resolve('baz/', fixtures), | |
| 32 | 34 | fixtures + 'node_modules/baz/'); | |
| 35 | + | ||
| 36 | + { | ||
| 37 | + const cp = spawn(execPath, [ | ||
| 38 | + '--experimental-import-meta-resolve', | ||
| 39 | + '--input-type=module', | ||
| 40 | + '--eval', 'console.log(typeof import.meta.resolve)', | ||
| 41 | + ]); | ||
| 42 | + assert.match((await cp.stdout.toArray()).toString(), /^function\r?\n$/); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + { | ||
| 46 | + const cp = spawn(execPath, [ | ||
| 47 | + '--experimental-import-meta-resolve', | ||
| 48 | + '--input-type=module', | ||
| 49 | + ]); | ||
| 50 | + cp.stdin.end('console.log(typeof import.meta.resolve)'); | ||
| 51 | + assert.match((await cp.stdout.toArray()).toString(), /^function\r?\n$/); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + { | ||
| 55 | + const cp = spawn(execPath, [ | ||
| 56 | + '--experimental-import-meta-resolve', | ||
| 57 | + '--input-type=module', | ||
| 58 | + '--eval', 'import "data:text/javascript,console.log(import.meta.resolve(%22node:os%22))"', | ||
| 59 | + ]); | ||
| 60 | + assert.match((await cp.stdout.toArray()).toString(), /^node:os\r?\n$/); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + { | ||
| 64 | + const cp = spawn(execPath, [ | ||
| 65 | + '--experimental-import-meta-resolve', | ||
| 66 | + '--input-type=module', | ||
| 67 | + ]); | ||
| 68 | + cp.stdin.end('import "data:text/javascript,console.log(import.meta.resolve(%22node:os%22))"'); | ||
| 69 | + assert.match((await cp.stdout.toArray()).toString(), /^node:os\r?\n$/); | ||
| 70 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments