-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
module,src: support loading entrypoint as url
Co-Authored-By: Antoine du Hamel <[email protected]>
- Loading branch information
1 parent
75e4d0d
commit 9d90d6c
Showing
7 changed files
with
128 additions
and
6 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
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,85 @@ | ||
import { spawnPromisified } from '../common/index.mjs'; | ||
import * as fixtures from '../common/fixtures.mjs'; | ||
import assert from 'node:assert'; | ||
import { execPath } from 'node:process'; | ||
import { describe, it } from 'node:test'; | ||
|
||
describe('--entry-url', { concurrency: true }, () => { | ||
it('should reject loading absolute path that contains %', async () => { | ||
const { code, signal, stderr, stdout } = await spawnPromisified( | ||
execPath, | ||
[ | ||
'--entry-url', | ||
fixtures.path('es-modules/test-esm-double-encoding-native%20.mjs'), | ||
] | ||
); | ||
|
||
assert.match(stderr, /ERR_MODULE_NOT_FOUND/); | ||
assert.strictEqual(stdout, ''); | ||
assert.strictEqual(code, 1); | ||
assert.strictEqual(signal, null); | ||
}); | ||
|
||
it('should support loading absolute Unix path properly encoded', async () => { | ||
const { code, signal, stderr, stdout } = await spawnPromisified( | ||
execPath, | ||
[ | ||
'--entry-url', | ||
fixtures.fileURL('es-modules/test-esm-double-encoding-native%20.mjs').pathname, | ||
] | ||
); | ||
|
||
assert.match(stderr, /--entry-url is an experimental feature/); | ||
assert.strictEqual(stdout, ''); | ||
assert.strictEqual(code, 0); | ||
assert.strictEqual(signal, null); | ||
}); | ||
|
||
it('should support loading absolute URLs', async () => { | ||
const { code, signal, stderr, stdout } = await spawnPromisified( | ||
execPath, | ||
[ | ||
'--entry-url', | ||
fixtures.fileURL('printA.js'), | ||
] | ||
); | ||
|
||
assert.match(stderr, /--entry-url is an experimental feature/); | ||
assert.match(stdout, /^A\r?\n$/); | ||
assert.strictEqual(code, 0); | ||
assert.strictEqual(signal, null); | ||
}); | ||
|
||
it('should support loading relative URLs', async () => { | ||
const { code, signal, stderr, stdout } = await spawnPromisified( | ||
execPath, | ||
[ | ||
'--entry-url', | ||
'./printA.js?key=value', | ||
], | ||
{ | ||
cwd: fixtures.fileURL('./'), | ||
} | ||
); | ||
|
||
assert.match(stderr, /--entry-url is an experimental feature/); | ||
assert.match(stdout, /^A\r?\n$/); | ||
assert.strictEqual(code, 0); | ||
assert.strictEqual(signal, null); | ||
}); | ||
|
||
it('should support loading `data:` URLs', async () => { | ||
const { code, signal, stderr, stdout } = await spawnPromisified( | ||
execPath, | ||
[ | ||
'--entry-url', | ||
'data:text/javascript,console.log(0)', | ||
], | ||
); | ||
|
||
assert.match(stderr, /--entry-url is an experimental feature/); | ||
assert.match(stdout, /^0\r?\n$/); | ||
assert.strictEqual(code, 0); | ||
assert.strictEqual(signal, null); | ||
}); | ||
}); |