mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
d89ae8f012
Fixes #20700. Patch global `WeakMap` before loading plugins to make a `WeakMap` keyed by `context.sourceCode` act as if every file has a unique `context.sourceCode`. The runtime cost of this patch is very low - for the use case of `WeakMap` keyed by `SourceCode`, it should be *faster* than an actual `WeakMap`, as no methods do actual hash map lookups. The implementation takes care not to leak memory even if plugins use `WeakMap`s extensively or in pathological patterns. I rebased #20611 on top of this, and after this PR, 100% of `eslint-plugin-mocha`'s conformance tests pass. It's pretty hacky to be patching globals, but I believe the implementation to be robust. My rationale for this solution is explained in detail in #20700.
31 lines
743 B
TypeScript
31 lines
743 B
TypeScript
import { defineConfig } from "vitest/config";
|
|
|
|
export default defineConfig({
|
|
define: {
|
|
DEBUG: "true",
|
|
CONFORMANCE: "false",
|
|
},
|
|
test: {
|
|
projects: [
|
|
{
|
|
extends: true,
|
|
test: {
|
|
name: "tests",
|
|
include: ["test/**/*.test.ts"],
|
|
exclude: ["test/**/*.isolated.test.ts"],
|
|
},
|
|
},
|
|
{
|
|
// Tests matching `*.isolated.test.ts` run in separate child processes (via `forks` pool)
|
|
// to prevent side effects (e.g. patching `globalThis.WeakMap`) from leaking into other unit tests.
|
|
extends: true,
|
|
test: {
|
|
name: "isolated",
|
|
include: ["test/**/*.isolated.test.ts"],
|
|
pool: "forks",
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|