@vitest/web-worker 1.5.2 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -0
- package/dist/pure.js +8 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
package/dist/pure.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { VitestExecutor } from 'vitest/execute';
|
2
|
+
import { readFileSync } from 'node:fs';
|
2
3
|
import createDebug from 'debug';
|
3
4
|
import { MessageChannel } from 'node:worker_threads';
|
4
5
|
|
@@ -327,8 +328,13 @@ function getRunnerOptions() {
|
|
327
328
|
const state = getWorkerState();
|
328
329
|
const { config, rpc, mockMap, moduleCache } = state;
|
329
330
|
return {
|
330
|
-
fetchModule(id) {
|
331
|
-
|
331
|
+
async fetchModule(id) {
|
332
|
+
const result = await rpc.fetch(id, "web");
|
333
|
+
if (result.id && !result.externalize) {
|
334
|
+
const code = readFileSync(result.id, "utf-8");
|
335
|
+
return { code };
|
336
|
+
}
|
337
|
+
return result;
|
332
338
|
},
|
333
339
|
resolveId(id, importer) {
|
334
340
|
return rpc.resolveId(id, importer, "web");
|