@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 CHANGED
@@ -1,5 +1,6 @@
1
1
  import { defineWebWorkers } from './pure.js';
2
2
  import 'vitest/execute';
3
+ import 'node:fs';
3
4
  import 'debug';
4
5
  import 'node:worker_threads';
5
6
 
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
- return rpc.fetch(id, "web");
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");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/web-worker",
3
3
  "type": "module",
4
- "version": "1.5.2",
4
+ "version": "1.6.0",
5
5
  "description": "Web Worker support for testing in Vitest",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",