Skip to content

Commit

Permalink
Inject node:url polyfill into the Vitest integration
Browse files Browse the repository at this point in the history
  • Loading branch information
penalosa committed Sep 11, 2024
1 parent ebaaab6 commit 852e8f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/vitest-pool-workers/src/pool/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ const __dirname = path.dirname(__filename);
const DIST_PATH = path.resolve(__dirname, "..");
const POOL_WORKER_PATH = path.join(DIST_PATH, "worker", "index.mjs");

const NODE_URL_PATH = path.join(DIST_PATH, "worker", "lib", "node", "url.mjs");

const symbolizerWarning =
"warning: Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set.";
const ignoreMessages = [
Expand Down Expand Up @@ -486,6 +488,13 @@ function buildProjectWorkerOptions(
path: path.join(modulesRoot, DEFINES_MODULE_PATH),
contents: defines,
},
// The workerd provided `node:url` module doesn't support everything Vitest needs.
// As a short-term fix, inject a `node:url` polyfill into the worker bundle
{
type: "ESModule",
path: path.join(modulesRoot, "node:url"),
contents: fs.readFileSync(NODE_URL_PATH),
},
];

// Build array of workers contributed by the workspace
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 852e8f3

Please sign in to comment.