-
-
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(vite-node): externalize network imports (#4987)
- Loading branch information
Showing
8 changed files
with
62 additions
and
3 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,11 @@ | ||
{ | ||
"name": "@vitest/test-network-imports", | ||
"type": "module", | ||
"private": true, | ||
"scripts": { | ||
"test": "vitest" | ||
}, | ||
"devDependencies": { | ||
"vitest": "workspace:*" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,11 @@ | ||
import { expect, test } from 'vitest' | ||
|
||
// @ts-expect-error network imports | ||
import slash from 'http://localhost:9602/slash@3.0.0.js' | ||
|
||
// test without local server | ||
// import slash from 'https://esm.sh/slash@3.0.0' | ||
|
||
test('network imports', () => { | ||
expect(slash('foo\\bar')).toBe('foo/bar') | ||
}) |
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,24 @@ | ||
import { defineConfig } from 'vitest/config' | ||
|
||
export default defineConfig({ | ||
test: { | ||
poolOptions: { | ||
threads: { | ||
execArgv: ['--experimental-network-imports'], | ||
}, | ||
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/slash@3.0.0.js' | ||
// ❯ Object.openSync node:fs:596:3 | ||
// ❯ readFileSync node:fs:464:35 | ||
vmThreads: { | ||
execArgv: ['--experimental-network-imports'], | ||
}, | ||
}, | ||
// let vite serve public/slash@3.0.0.js | ||
api: 9602, | ||
}, | ||
}) |