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.
7 lines
200 B
TypeScript
7 lines
200 B
TypeScript
// Patch `WeakMap` before any plugins are loaded
|
|
import "./weak_map.ts";
|
|
|
|
export { lintFile } from "./lint.ts";
|
|
export { loadPlugin } from "./load.ts";
|
|
export { setupRuleConfigs } from "./config.ts";
|