|
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 | +} |
0 commit comments