Compare commits

...

8 Commits

Author SHA1 Message Date
hai-x 18e6e640e2
Merge 4abdfa94df into 9f98d803c0 2025-10-06 14:10:18 +08:00
Alexander Akait 9f98d803c0
fix: javascript parser options types (#19980)
Github Actions / lint (push) Has been cancelled Details
Github Actions / validate-legacy-node (push) Has been cancelled Details
Github Actions / benchmark (1/4) (push) Has been cancelled Details
Github Actions / benchmark (2/4) (push) Has been cancelled Details
Github Actions / benchmark (3/4) (push) Has been cancelled Details
Github Actions / benchmark (4/4) (push) Has been cancelled Details
Github Actions / basic (push) Has been cancelled Details
Github Actions / unit (push) Has been cancelled Details
Github Actions / integration (10.x, macos-latest, a) (push) Has been cancelled Details
Github Actions / integration (10.x, macos-latest, b) (push) Has been cancelled Details
Github Actions / integration (10.x, ubuntu-latest, a) (push) Has been cancelled Details
Github Actions / integration (10.x, ubuntu-latest, b) (push) Has been cancelled Details
Github Actions / integration (10.x, windows-latest, a) (push) Has been cancelled Details
Github Actions / integration (10.x, windows-latest, b) (push) Has been cancelled Details
Github Actions / integration (12.x, ubuntu-latest, a) (push) Has been cancelled Details
Github Actions / integration (14.x, ubuntu-latest, a) (push) Has been cancelled Details
Github Actions / integration (16.x, ubuntu-latest, a) (push) Has been cancelled Details
Github Actions / integration (18.x, ubuntu-latest, a) (push) Has been cancelled Details
Github Actions / integration (20.x, macos-latest, a) (push) Has been cancelled Details
Github Actions / integration (20.x, macos-latest, b) (push) Has been cancelled Details
Github Actions / integration (20.x, ubuntu-latest, a) (push) Has been cancelled Details
Github Actions / integration (20.x, ubuntu-latest, b) (push) Has been cancelled Details
Github Actions / integration (20.x, windows-latest, a) (push) Has been cancelled Details
Github Actions / integration (20.x, windows-latest, b) (push) Has been cancelled Details
Github Actions / integration (22.x, macos-latest, a) (push) Has been cancelled Details
Github Actions / integration (22.x, macos-latest, b) (push) Has been cancelled Details
Github Actions / integration (22.x, ubuntu-latest, a) (push) Has been cancelled Details
Github Actions / integration (22.x, ubuntu-latest, b) (push) Has been cancelled Details
Github Actions / integration (22.x, windows-latest, a) (push) Has been cancelled Details
Github Actions / integration (22.x, windows-latest, b) (push) Has been cancelled Details
Github Actions / integration (24.x, macos-latest, a) (push) Has been cancelled Details
Github Actions / integration (24.x, macos-latest, b) (push) Has been cancelled Details
Github Actions / integration (24.x, ubuntu-latest, a) (push) Has been cancelled Details
Github Actions / integration (24.x, ubuntu-latest, b) (push) Has been cancelled Details
Github Actions / integration (24.x, windows-latest, a) (push) Has been cancelled Details
Github Actions / integration (24.x, windows-latest, b) (push) Has been cancelled Details
Github Actions / integration (lts/*, ubuntu-latest, a, 1) (push) Has been cancelled Details
Github Actions / integration (lts/*, ubuntu-latest, b, 1) (push) Has been cancelled Details
Update examples / examples (push) Has been cancelled Details
2025-10-04 14:58:38 +03:00
dependabot[bot] 8804459884
chore(deps): bump CodSpeedHQ/action from 4.0.1 to 4.1.0 (#19977)
Bumps [CodSpeedHQ/action](https://github.com/codspeedhq/action) from 4.0.1 to 4.1.0.
- [Release notes](https://github.com/codspeedhq/action/releases)
- [Changelog](https://github.com/CodSpeedHQ/action/blob/main/CHANGELOG.md)
- [Commits](653fdc30e6...3959e9e296)

---
updated-dependencies:
- dependency-name: CodSpeedHQ/action
  dependency-version: 4.1.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-04 13:32:45 +03:00
Alexander Akait bc91301142
chore: update codespeed (#19959) 2025-10-04 13:26:48 +03:00
Hai 4abdfa94df fix 2025-09-30 23:39:56 +08:00
Hai 4587dbb336 fix 2025-09-30 02:42:01 +08:00
Hai c056283928 fix 2025-09-30 02:26:28 +08:00
Hai 5604ce9b89 feat: support ignoreList 2025-09-30 02:26:28 +08:00
22 changed files with 407 additions and 131 deletions

View File

@ -97,7 +97,7 @@ jobs:
- run: yarn link webpack --frozen-lockfile - run: yarn link webpack --frozen-lockfile
- name: Run benchmarks - name: Run benchmarks
uses: CodSpeedHQ/action@653fdc30e6c40ffd9739e40c8a0576f4f4523ca1 # v4.0.1 uses: CodSpeedHQ/action@3959e9e296ef25296e93e32afcc97196f966e57f # v4.1.0
with: with:
run: yarn benchmark --ci run: yarn benchmark --ci
mode: "instrumentation" mode: "instrumentation"

View File

@ -284,6 +284,7 @@
"url's", "url's",
"valign", "valign",
"valtype", "valtype",
"walltime",
"wasi", "wasi",
"wasm", "wasm",
"watchings", "watchings",
@ -304,7 +305,6 @@
"commithash", "commithash",
"formaters", "formaters",
"akait", "akait",
"Akait",
"evenstensberg", "evenstensberg",
"Stensberg", "Stensberg",
"ovflowd", "ovflowd",

View File

@ -3349,7 +3349,6 @@ export interface JavascriptParserOptions {
* Set the inner regular expression for partial dynamic dependencies. * Set the inner regular expression for partial dynamic dependencies.
*/ */
wrappedContextRegExp?: RegExp; wrappedContextRegExp?: RegExp;
[k: string]: any;
} }
/** /**
* Generator options for json modules. * Generator options for json modules.

View File

@ -5,11 +5,11 @@
*/ */
/** /**
* Include source maps for modules based on their extension (defaults to .js and .css). * One or multiple conditions used to match resource.
*/ */
export type Rules = Rule[] | Rule; export type Rules = Rule[] | Rule;
/** /**
* Include source maps for modules based on their extension (defaults to .js and .css). * Condition used to match resource (string, RegExp or Function).
*/ */
export type Rule = RegExp | string | ((str: string) => boolean); export type Rule = RegExp | string | ((str: string) => boolean);
@ -47,6 +47,10 @@ export interface SourceMapDevToolPluginOptions {
* Defines the output filename of the SourceMap (will be inlined if no value is provided). * Defines the output filename of the SourceMap (will be inlined if no value is provided).
*/ */
filename?: (false | null) | string; filename?: (false | null) | string;
/**
* Decide whether to ignore source files that match the specified value in the SourceMap.
*/
ignoreList?: Rules;
/** /**
* Include source maps for module paths that match the given value. * Include source maps for module paths that match the given value.
*/ */

View File

@ -18,6 +18,7 @@ const { makePathsAbsolute } = require("./util/identifier");
/** @typedef {import("webpack-sources").RawSourceMap} RawSourceMap */ /** @typedef {import("webpack-sources").RawSourceMap} RawSourceMap */
/** @typedef {import("webpack-sources").Source} Source */ /** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */ /** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").Rules} Rules */
/** @typedef {import("./ChunkGraph").ModuleId} ModuleId */ /** @typedef {import("./ChunkGraph").ModuleId} ModuleId */
/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./Compiler")} Compiler */
@ -163,6 +164,21 @@ class EvalSourceMapDevToolPlugin {
} }
); );
sourceMap.sources = moduleFilenames; sourceMap.sources = moduleFilenames;
sourceMap.ignoreList = options.ignoreList
? sourceMap.sources.reduce(
/** @type {(acc: number[], sourceName: string, idx: number) => number[]} */ (
(acc, sourceName, idx) => {
const rule = /** @type {Rules} */ (options.ignoreList);
if (ModuleFilenameHelpers.matchPart(sourceName, rule)) {
acc.push(idx);
}
return acc;
}
),
[]
)
: [];
if (options.noSources) { if (options.noSources) {
sourceMap.sourcesContent = undefined; sourceMap.sourcesContent = undefined;
} }

View File

@ -20,6 +20,7 @@ const { makePathsAbsolute } = require("./util/identifier");
/** @typedef {import("webpack-sources").MapOptions} MapOptions */ /** @typedef {import("webpack-sources").MapOptions} MapOptions */
/** @typedef {import("webpack-sources").Source} Source */ /** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */ /** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").Rules} Rules */
/** @typedef {import("./CacheFacade").ItemCacheFacade} ItemCacheFacade */ /** @typedef {import("./CacheFacade").ItemCacheFacade} ItemCacheFacade */
/** @typedef {import("./Chunk")} Chunk */ /** @typedef {import("./Chunk")} Chunk */
/** @typedef {import("./Compilation").Asset} Asset */ /** @typedef {import("./Compilation").Asset} Asset */
@ -433,6 +434,25 @@ class SourceMapDevToolPlugin {
moduleToSourceNameMapping.get(m) moduleToSourceNameMapping.get(m)
); );
sourceMap.sources = /** @type {string[]} */ (moduleFilenames); sourceMap.sources = /** @type {string[]} */ (moduleFilenames);
sourceMap.ignoreList = options.ignoreList
? sourceMap.sources.reduce(
/** @type {(acc: number[], sourceName: string, idx: number) => number[]} */ (
(acc, sourceName, idx) => {
const rule = /** @type {Rules} */ (
options.ignoreList
);
if (
ModuleFilenameHelpers.matchPart(sourceName, rule)
) {
acc.push(idx);
}
return acc;
}
),
[]
)
: [];
if (options.noSources) { if (options.noSources) {
sourceMap.sourcesContent = undefined; sourceMap.sourcesContent = undefined;
} }

View File

@ -110,7 +110,7 @@
"devDependencies": { "devDependencies": {
"@babel/core": "^7.27.1", "@babel/core": "^7.27.1",
"@babel/preset-react": "^7.27.1", "@babel/preset-react": "^7.27.1",
"@codspeed/core": "^4.0.1", "@codspeed/core": "^5.0.1",
"@eslint/js": "^9.36.0", "@eslint/js": "^9.36.0",
"@eslint/markdown": "^7.3.0", "@eslint/markdown": "^7.3.0",
"@stylistic/eslint-plugin": "^5.4.0", "@stylistic/eslint-plugin": "^5.4.0",

File diff suppressed because one or more lines are too long

View File

@ -1786,7 +1786,7 @@
"JavascriptParserOptions": { "JavascriptParserOptions": {
"description": "Parser options for javascript modules.", "description": "Parser options for javascript modules.",
"type": "object", "type": "object",
"additionalProperties": true, "additionalProperties": false,
"properties": { "properties": {
"amd": { "amd": {
"$ref": "#/definitions/Amd" "$ref": "#/definitions/Amd"

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{ {
"definitions": { "definitions": {
"rule": { "rule": {
"description": "Include source maps for modules based on their extension (defaults to .js and .css).", "description": "Condition used to match resource (string, RegExp or Function).",
"anyOf": [ "anyOf": [
{ {
"instanceof": "RegExp", "instanceof": "RegExp",
@ -18,7 +18,7 @@
] ]
}, },
"rules": { "rules": {
"description": "Include source maps for modules based on their extension (defaults to .js and .css).", "description": "One or multiple conditions used to match resource.",
"anyOf": [ "anyOf": [
{ {
"type": "array", "type": "array",
@ -106,6 +106,14 @@
} }
] ]
}, },
"ignoreList": {
"description": "Decide whether to ignore source files that match the specified value in the SourceMap.",
"oneOf": [
{
"$ref": "#/definitions/rules"
}
]
},
"include": { "include": {
"description": "Include source maps for module paths that match the given value.", "description": "Include source maps for module paths that match the given value.",
"oneOf": [ "oneOf": [
@ -149,7 +157,12 @@
"type": "string" "type": "string"
}, },
"test": { "test": {
"$ref": "#/definitions/rules" "description": "Include source maps for modules based on their extension (defaults to .js and .css).",
"oneOf": [
{
"$ref": "#/definitions/rules"
}
]
} }
} }
} }

View File

@ -3,6 +3,15 @@ import fs from "fs/promises";
import { Session } from "inspector"; import { Session } from "inspector";
import path from "path"; import path from "path";
import { fileURLToPath, pathToFileURL } from "url"; import { fileURLToPath, pathToFileURL } from "url";
import {
InstrumentHooks,
getCodspeedRunnerMode,
getGitDir,
getV8Flags,
mongoMeasurement,
setupCore,
teardownCore
} from "@codspeed/core";
import { simpleGit } from "simple-git"; import { simpleGit } from "simple-git";
import { Bench, hrtimeNow } from "tinybench"; import { Bench, hrtimeNow } from "tinybench";
@ -12,32 +21,6 @@ const git = simpleGit(rootPath);
const REV_LIST_REGEXP = /^([a-f0-9]+)\s*([a-f0-9]+)\s*([a-f0-9]+)?\s*$/; const REV_LIST_REGEXP = /^([a-f0-9]+)\s*([a-f0-9]+)\s*([a-f0-9]+)?\s*$/;
const getV8Flags = () => {
const nodeVersionMajor = Number.parseInt(
process.version.slice(1).split(".")[0],
10
);
const flags = [
"--hash-seed=1",
"--random-seed=1",
"--no-opt",
"--predictable",
"--predictable-gc-schedule",
"--interpreted-frames-native-stack",
"--allow-natives-syntax",
"--expose-gc",
"--no-concurrent-sweeping",
"--max-old-space-size=4096"
];
if (nodeVersionMajor < 18) {
flags.push("--no-randomize-hashes");
}
if (nodeVersionMajor < 20) {
flags.push("--no-scavenge-task");
}
return flags;
};
const checkV8Flags = () => { const checkV8Flags = () => {
const requiredFlags = getV8Flags(); const requiredFlags = getV8Flags();
const actualFlags = process.execArgv; const actualFlags = process.execArgv;
@ -248,6 +231,8 @@ for (const baselineInfo of baselineRevisions) {
} }
} }
const baseOutputPath = path.join(__dirname, "js", "benchmark");
function buildConfiguration( function buildConfiguration(
test, test,
baseline, baseline,
@ -385,105 +370,239 @@ const scenarios = [
} }
]; ];
const baseOutputPath = path.join(__dirname, "js", "benchmark"); function getStackTrace(belowFn) {
const oldLimit = Error.stackTraceLimit;
Error.stackTraceLimit = Infinity;
const dummyObject = {};
const v8Handler = Error.prepareStackTrace;
Error.prepareStackTrace = (dummyObject, v8StackTrace) => v8StackTrace;
Error.captureStackTrace(dummyObject, belowFn || getStackTrace);
const v8StackTrace = dummyObject.stack;
Error.prepareStackTrace = v8Handler;
Error.stackTraceLimit = oldLimit;
return v8StackTrace;
}
function getCallingFile() {
const stack = getStackTrace();
let callingFile = stack[2].getFileName(); // [here, withCodSpeed, actual caller]
const gitDir = getGitDir(callingFile);
if (gitDir === undefined) {
throw new Error("Could not find a git repository");
}
if (callingFile.startsWith("file://")) {
callingFile = fileURLToPath(callingFile);
}
return path.relative(gitDir, callingFile);
}
const taskUriMap = new WeakMap();
function getOrCreateUriMap(bench) {
let uriMap = taskUriMap.get(bench);
if (!uriMap) {
uriMap = new Map();
taskUriMap.set(bench, uriMap);
}
return uriMap;
}
function getTaskUri(bench, taskName, rootCallingFile) {
const uriMap = taskUriMap.get(bench);
return uriMap?.get(taskName) || `${rootCallingFile}::${taskName}`;
}
const withCodSpeed = async (/** @type {import("tinybench").Bench} */ bench) => { const withCodSpeed = async (/** @type {import("tinybench").Bench} */ bench) => {
const { Measurement, getGitDir, mongoMeasurement, setupCore, teardownCore } = const codspeedRunnerMode = getCodspeedRunnerMode();
await import("@codspeed/core");
if (!Measurement.isInstrumented()) { if (codspeedRunnerMode === "disabled") {
const rawRun = bench.run;
bench.run = async () => {
console.warn(
`[CodSpeed] ${bench.tasks.length} benches detected but no instrumentation found, falling back to tinybench`
);
return await rawRun.bind(bench)();
};
return bench; return bench;
} }
const getStackTrace = (belowFn) => {
const oldLimit = Error.stackTraceLimit;
Error.stackTraceLimit = Infinity;
const dummyObject = {};
const v8Handler = Error.prepareStackTrace;
Error.prepareStackTrace = (dummyObject, v8StackTrace) => v8StackTrace;
Error.captureStackTrace(dummyObject, belowFn || getStackTrace);
const v8StackTrace = dummyObject.stack;
Error.prepareStackTrace = v8Handler;
Error.stackTraceLimit = oldLimit;
return v8StackTrace;
};
const getCallingFile = () => {
const stack = getStackTrace();
let callingFile = stack[2].getFileName(); // [here, withCodSpeed, actual caller]
const gitDir = getGitDir(callingFile);
if (gitDir === undefined) {
throw new Error("Could not find a git repository");
}
if (callingFile.startsWith("file://")) {
callingFile = fileURLToPath(callingFile);
}
return path.relative(gitDir, callingFile);
};
const rawAdd = bench.add; const rawAdd = bench.add;
const uriMap = getOrCreateUriMap(bench);
bench.add = (name, fn, opts) => { bench.add = (name, fn, opts) => {
const callingFile = getCallingFile(); const callingFile = getCallingFile();
const uri = `${callingFile}::${name}`; let uri = callingFile;
const options = { ...opts, uri }; if (bench.name !== undefined) {
return rawAdd.bind(bench)(name, fn, options); uri += `::${bench.name}`;
}
uri += `::${name}`;
uriMap.set(name, uri);
return rawAdd.bind(bench)(name, fn, opts);
}; };
const rootCallingFile = getCallingFile(); const rootCallingFile = getCallingFile();
bench.run = async function run() {
const iterations = bench.opts.iterations - 1; if (codspeedRunnerMode === "instrumented") {
console.log("[CodSpeed] running"); const setupBenchRun = () => {
setupCore(); setupCore();
for (const task of bench.tasks) { console.log(
await bench.opts.setup?.(task, "run"); "[CodSpeed] running with @codspeed/tinybench (instrumented mode)"
await task.fnOpts.beforeAll?.call(task); );
const samples = []; };
async function iteration() { const finalizeBenchRun = () => {
try { teardownCore();
await task.fnOpts.beforeEach?.call(task, "run"); console.log(`[CodSpeed] Done running ${bench.tasks.length} benches.`);
const start = bench.opts.now(); return bench.tasks;
await task.fn(); };
samples.push(bench.opts.now() - start || 0);
await task.fnOpts.afterEach?.call(this, "run"); const wrapFunctionWithFrame = (fn, isAsync) => {
} catch (err) { if (isAsync) {
if (bench.opts.throws) { return async function __codspeed_root_frame__() {
throw err; await fn();
} };
}
return function __codspeed_root_frame__() {
fn();
};
};
const logTaskCompletion = (uri, status) => {
console.log(`[CodSpeed] ${status} ${uri}`);
};
const taskCompletionMessage = () =>
InstrumentHooks.isInstrumented() ? "Measured" : "Checked";
const iterationAsync = async (task) => {
try {
await task.fnOpts.beforeEach?.call(task, "run");
const start = bench.opts.now();
await task.fn();
const end = bench.opts.now() - start || 0;
await task.fnOpts.afterEach?.call(this, "run");
return [start, end];
} catch (err) {
if (bench.opts.throws) {
throw err;
} }
} }
while (samples.length < iterations) { };
await iteration();
}
// Codspeed Measure
const uri =
task.opts && "uri" in task.options
? task.opts.uri
: `${rootCallingFile}::${task.name}`;
await task.fnOpts.beforeEach?.call(task);
await mongoMeasurement.start(uri);
await (async function __codspeed_root_frame__() {
Measurement.startInstrumentation();
await task.fn();
Measurement.stopInstrumentation(uri);
})();
await mongoMeasurement.stop(uri);
await task.fnOpts.afterEach?.call(task);
console.log(`[Codspeed] ✔ Measured ${uri}`);
await task.fnOpts.afterAll?.call(task);
const wrapWithInstrumentHooksAsync = async (fn, uri) => {
InstrumentHooks.startBenchmark();
const result = await fn();
InstrumentHooks.stopBenchmark();
InstrumentHooks.setExecutedBenchmark(process.pid, uri);
return result;
};
const runTaskAsync = async (task, uri) => {
const { fnOpts, fn } = task;
// Custom setup
await bench.opts.setup?.(task, "run");
await fnOpts?.beforeAll?.call(task, "run");
// Custom warmup
// We don't run `optimizeFunction` because our function is never optimized, instead we just warmup webpack
const samples = [];
while (samples.length < bench.opts.iterations - 1) {
samples.push(await iterationAsync(task));
}
await fnOpts?.beforeEach?.call(task, "run");
await mongoMeasurement.start(uri);
global.gc?.();
await wrapWithInstrumentHooksAsync(wrapFunctionWithFrame(fn, true), uri);
await mongoMeasurement.stop(uri);
await fnOpts?.afterEach?.call(task, "run");
console.log(`[Codspeed] ✔ Measured ${uri}`);
await fnOpts?.afterAll?.call(task, "run");
// Custom teardown
await bench.opts.teardown?.(task, "run"); await bench.opts.teardown?.(task, "run");
task.processRunResult({ latencySamples: samples });
} logTaskCompletion(uri, taskCompletionMessage());
teardownCore(); };
console.log(`[CodSpeed] Done running ${bench.tasks.length} benches.`);
return bench.tasks; const iteration = (task) => {
}; try {
task.fnOpts.beforeEach?.call(task, "run");
const start = bench.opts.now();
task.fn();
const end = bench.opts.now() - start || 0;
task.fnOpts.afterEach?.call(this, "run");
return [start, end];
} catch (err) {
if (bench.opts.throws) {
throw err;
}
}
};
const wrapWithInstrumentHooks = (fn, uri) => {
InstrumentHooks.startBenchmark();
const result = fn();
InstrumentHooks.stopBenchmark();
InstrumentHooks.setExecutedBenchmark(process.pid, uri);
return result;
};
const runTaskSync = (task, uri) => {
const { fnOpts, fn } = task;
// Custom setup
bench.opts.setup?.(task, "run");
fnOpts?.beforeAll?.call(task, "run");
// Custom warmup
const samples = [];
while (samples.length < bench.opts.iterations - 1) {
samples.push(iteration(task));
}
fnOpts?.beforeEach?.call(task, "run");
wrapWithInstrumentHooks(wrapFunctionWithFrame(fn, false), uri);
fnOpts?.afterEach?.call(task, "run");
console.log(`[Codspeed] ✔ Measured ${uri}`);
fnOpts?.afterAll?.call(task, "run");
// Custom teardown
bench.opts.teardown?.(task, "run");
logTaskCompletion(uri, taskCompletionMessage());
};
const finalizeAsyncRun = () => {
finalizeBenchRun();
};
const finalizeSyncRun = () => {
finalizeBenchRun();
};
bench.run = async () => {
setupBenchRun();
for (const task of bench.tasks) {
const uri = getTaskUri(task.bench, task.name, rootCallingFile);
await runTaskAsync(task, uri);
}
return finalizeAsyncRun();
};
bench.runSync = () => {
setupBenchRun();
for (const task of bench.tasks) {
const uri = getTaskUri(task.bench, task.name, rootCallingFile);
runTaskSync(task, uri);
}
return finalizeSyncRun();
};
} else if (codspeedRunnerMode === "walltime") {
// We don't need it
}
return bench; return bench;
}; };
@ -495,7 +614,6 @@ const bench = await withCodSpeed(
warmupIterations: 2, warmupIterations: 2,
iterations: 8, iterations: 8,
setup(task, mode) { setup(task, mode) {
global.gc();
console.log(`Setup (${mode} mode): ${task.name}`); console.log(`Setup (${mode} mode): ${task.name}`);
}, },
teardown(task, mode) { teardown(task, mode) {

View File

@ -0,0 +1 @@
export default "ignored";

View File

@ -0,0 +1,34 @@
import used from "./used";
import ignored from "./ignored";
import fs from "fs";
const getSourceMap = () => {
const source = fs.readFileSync(__filename, "utf-8");
const match =
/\/\/# sourceMappingURL\s*=\s*data:application\/json;charset=utf-8;base64,(.*)\\n\/\/#/.exec(
source
);
const mapString = Buffer.from(match[1], "base64").toString("utf-8");
return JSON.parse(mapString);
};
const map = getSourceMap();
it("marks matching modules in ignoreList", () => {
const sources = map.sources;
const ignoredIndex = sources.findIndex((source) =>
/ignored\.js/.test(source)
);
expect(ignored).toBe("ignored");
expect(ignoredIndex).not.toBe(-1);
expect(Array.isArray(map.ignoreList)).toBe(true);
expect(map.ignoreList).toContain(ignoredIndex);
});
it("keeps other modules outside ignoreList", () => {
const sources = map.sources;
const usedIndex = sources.findIndex((source) => /used\.js/.test(source));
expect(used).toBe("used");
expect(usedIndex).not.toBe(-1);
expect(map.ignoreList).not.toContain(usedIndex);
});

View File

@ -0,0 +1 @@
export default "used";

View File

@ -0,0 +1,17 @@
"use strict";
const webpack = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
devtool: false,
plugins: [
new webpack.EvalSourceMapDevToolPlugin({
ignoreList: [/ignored\.js/]
})
],
optimization: {
// Ensure the correct `sourceMappingURL` is detected
concatenateModules: true
}
};

View File

@ -0,0 +1 @@
export default "ignored";

View File

@ -0,0 +1,33 @@
import used from "./used";
import ignored from "./ignored";
import fs from "fs";
import path from "path";
const getSourceMap = () => {
const content = fs.readFileSync(
path.join(__dirname, "bundle0.js.map"),
"utf-8"
);
return JSON.parse(content);
};
const map = getSourceMap();
it("marks matching modules in ignoreList", () => {
const sources = map.sources;
const ignoredIndex = sources.findIndex((source) =>
/ignored\.js/.test(source)
);
expect(ignored).toBe("ignored");
expect(ignoredIndex).not.toBe(-1);
expect(Array.isArray(map.ignoreList)).toBe(true);
expect(map.ignoreList).toContain(ignoredIndex);
});
it("keeps other modules outside ignoreList", () => {
const sources = map.sources;
const usedIndex = sources.findIndex((source) => /used\.js/.test(source));
expect(used).toBe("used");
expect(usedIndex).not.toBe(-1);
expect(map.ignoreList).not.toContain(usedIndex);
});

View File

@ -0,0 +1 @@
export default "used";

View File

@ -0,0 +1,15 @@
"use strict";
const webpack = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "development",
devtool: false,
plugins: [
new webpack.SourceMapDevToolPlugin({
filename: "[file].map",
ignoreList: [/ignored\.js/]
})
]
};

7
types.d.ts vendored
View File

@ -8195,8 +8195,6 @@ declare class JavascriptParser extends ParserClass {
* Parser options for javascript modules. * Parser options for javascript modules.
*/ */
declare interface JavascriptParserOptions { declare interface JavascriptParserOptions {
[index: string]: any;
/** /**
* Set the value of `require.amd` and `define.amd`. Or disable AMD support. * Set the value of `require.amd` and `define.amd`. Or disable AMD support.
*/ */
@ -16833,6 +16831,11 @@ declare interface SourceMapDevToolPluginOptions {
*/ */
filename?: null | string | false; filename?: null | string | false;
/**
* Decide whether to ignore source files that match the specified value in the SourceMap.
*/
ignoreList?: string | RegExp | Rule[] | ((str: string) => boolean);
/** /**
* Include source maps for module paths that match the given value. * Include source maps for module paths that match the given value.
*/ */

View File

@ -332,14 +332,14 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@codspeed/core@^4.0.1": "@codspeed/core@^5.0.1":
version "4.0.1" version "5.0.1"
resolved "https://registry.yarnpkg.com/@codspeed/core/-/core-4.0.1.tgz#91049cce17b8c1d1b4b6cbc481f5ddc1145d6e1e" resolved "https://registry.yarnpkg.com/@codspeed/core/-/core-5.0.1.tgz#6145c898a86a6d56a169611c3e9657a8b97c7642"
integrity sha512-fJ53arfgtzCDZa8DuGJhpTZ3Ll9A1uW5nQ2jSJnfO4Hl5MRD2cP8P4vPvIUAGbdbjwCxR1jat6cW8OloMJkJXw== integrity sha512-4g5ZyFAin8QywK4+0FK1uXG3GLRPu0oc3xbP+7OUhhFxbwpzFuaJtKmnTofMqLy9/pHH6Bl/7H0/DTVH3cpFkA==
dependencies: dependencies:
axios "^1.4.0" axios "^1.4.0"
find-up "^6.3.0" find-up "^6.3.0"
form-data "^4.0.0" form-data "^4.0.4"
node-gyp-build "^4.6.0" node-gyp-build "^4.6.0"
"@cspell/cspell-bundled-dicts@9.1.3": "@cspell/cspell-bundled-dicts@9.1.3":
@ -3878,7 +3878,7 @@ fork-ts-checker-webpack-plugin@^9.0.2:
semver "^7.3.5" semver "^7.3.5"
tapable "^2.2.1" tapable "^2.2.1"
form-data@^4.0.0, form-data@^4.0.4: form-data@^4.0.4:
version "4.0.4" version "4.0.4"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.4.tgz#784cdcce0669a9d68e94d11ac4eea98088edd2c4" resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.4.tgz#784cdcce0669a9d68e94d11ac4eea98088edd2c4"
integrity sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow== integrity sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==