-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(vm): support network imports (#5610)
- Loading branch information
1 parent
cc8f058
commit 103a600
Showing
5 changed files
with
88 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,10 @@ import slash from 'http://localhost:9602/[email protected]' | |
test('network imports', () => { | ||
expect(slash('foo\\bar')).toBe('foo/bar') | ||
}) | ||
|
||
test('doesn\'t work for http outside localhost', async () => { | ||
// @ts-expect-error network imports | ||
await expect(() => import('http://100.0.0.0/')).rejects.toThrowError( | ||
'import of \'http://100.0.0.0/\' by undefined is not supported: http can only be used to load local resources (use https instead).', | ||
) | ||
}) |
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 |
---|---|---|
|
@@ -9,11 +9,6 @@ const config = { | |
forks: { | ||
execArgv: ['--experimental-network-imports'], | ||
}, | ||
// not supported? | ||
// FAIL test/basic.test.ts [ test/basic.test.ts ] | ||
// Error: ENOENT: no such file or directory, open 'http://localhost:9602/[email protected]' | ||
// ❯ Object.openSync node:fs:596:3 | ||
// ❯ readFileSync node:fs:464:35 | ||
vmThreads: { | ||
execArgv: ['--experimental-network-imports'], | ||
}, | ||
|
@@ -25,7 +20,7 @@ const config = { | |
it.each([ | ||
'threads', | ||
'forks', | ||
// 'vmThreads', | ||
'vmThreads', | ||
])('importing from network in %s', async (pool) => { | ||
const { stderr, exitCode } = await runVitest({ | ||
...config, | ||
|