perf: bundle vitest's own dependencies (#10685)

This commit is contained in:
Vladimir
2026-07-24 09:45:23 +02:00
committed by GitHub
parent bf2b1eb991
commit dc2fa1007c
13 changed files with 238 additions and 36 deletions
+1
View File
@@ -0,0 +1 @@
export * from './dist/display.js'
+13 -1
View File
@@ -17,54 +17,66 @@
"sideEffects": false,
"exports": {
".": {
"__vitest_source__": "./src/index.ts",
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./diff": {
"__vitest_source__": "./src/diff/index.ts",
"types": "./dist/diff.d.ts",
"default": "./dist/diff.js"
},
"./resolver": {
"__vitest_source__": "./src/resolver.ts",
"types": "./dist/resolver.d.ts",
"default": "./dist/resolver.js"
},
"./error": {
"__vitest_source__": "./src/error.ts",
"types": "./dist/error.d.ts",
"default": "./dist/error.js"
},
"./helpers": {
"__vitest_source__": "./src/helpers.ts",
"types": "./dist/helpers.d.ts",
"default": "./dist/helpers.js"
},
"./offset": {
"__vitest_source__": "./src/offset.ts",
"types": "./dist/offset.d.ts",
"default": "./dist/offset.js"
},
"./constants": {
"__vitest_source__": "./src/constants.ts",
"types": "./dist/constants.d.ts",
"default": "./dist/constants.js"
},
"./timers": {
"__vitest_source__": "./src/timers.ts",
"types": "./dist/timers.d.ts",
"default": "./dist/timers.js"
},
"./display": {
"__vitest_source__": "./src/display.ts",
"types": "./dist/display.d.ts",
"default": "./dist/display.js"
},
"./source-map": {
"__vitest_source__": "./src/source-map.ts",
"types": "./dist/source-map.d.ts",
"default": "./dist/source-map.js"
},
"./source-map/node": {
"__vitest_source__": "./src/source-map/node.ts",
"types": "./dist/source-map/node.d.ts",
"default": "./dist/source-map/node.js"
},
"./serialize": {
"__vitest_source__": "./src/serialize.ts",
"types": "./dist/serialize.d.ts",
"default": "./dist/serialize.js"
},
"./*": "./*"
"./package.json": "./package.json"
},
"main": "./dist/index.js",
"module": "./dist/index.js",
+1
View File
@@ -0,0 +1 @@
export * from './dist/timers.js'
+164
View File
@@ -316,6 +316,65 @@ Repository: egoist/cac
---------------------------------------
## convert-source-map
License: MIT
By: Thorsten Lorenz
Repository: git://github.com/thlorenz/convert-source-map.git
> Copyright 2013 Thorsten Lorenz.
> All rights reserved.
>
> Permission is hereby granted, free of charge, to any person
> obtaining a copy of this software and associated documentation
> files (the "Software"), to deal in the Software without
> restriction, including without limitation the rights to use,
> copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the
> Software is furnished to do so, subject to the following
> conditions:
>
> The above copyright notice and this permission notice shall be
> included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
> OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
> HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
> WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------
## diff-sequences
License: MIT
Repository: https://github.com/jestjs/jest.git
> MIT License
>
> Copyright (c) Meta Platforms, Inc. and affiliates.
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all
> copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
---------------------------------------
## flatted
License: ISC
By: Andrea Giammarchi
@@ -519,6 +578,83 @@ Repository: git+https://github.com/antfu-collective/package-manager-detector.git
---------------------------------------
## pathe
License: MIT
Repository: unjs/pathe
> MIT License
>
> Copyright (c) Pooya Parsa <[email protected]> - Daniel Roe <[email protected]>
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all
> copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
>
> ---
>
> Copyright Joyent, Inc. and other Node contributors.
>
> Permission is hereby granted, free of charge, to any person obtaining a
> copy of this software and associated documentation files (the
> "Software"), to deal in the Software without restriction, including
> without limitation the rights to use, copy, modify, merge, publish,
> distribute, sublicense, and/or sell copies of the Software, and to permit
> persons to whom the Software is furnished to do so, subject to the
> following conditions:
>
> The above copyright notice and this permission notice shall be included
> in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
> OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
> NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
> DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
> OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
> USE OR OTHER DEALINGS IN THE SOFTWARE.
>
> ---
>
> Bundled zeptomatch (https://github.com/fabiospampinato/zeptomatch)
>
> The MIT License (MIT)
>
> Copyright (c) 2023-present Fabio Spampinato
>
> Permission is hereby granted, free of charge, to any person obtaining a
> copy of this software and associated documentation files (the "Software"),
> to deal in the Software without restriction, including without limitation
> the rights to use, copy, modify, merge, publish, distribute, sublicense,
> and/or sell copies of the Software, and to permit persons to whom the
> Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> DEALINGS IN THE SOFTWARE.
---------------------------------------
## prompts
License: MIT
By: Terkel Gjervig
@@ -719,6 +855,34 @@ Repository: git+https://github.com/tinylibs/tinyhighlight.git
---------------------------------------
## tinyrainbow
License: MIT
Repository: git+https://github.com/tinylibs/tinyrainbow.git
> MIT License
>
> Copyright (c) 2022 Tinylibs
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all
> copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
---------------------------------------
## type-detect
License: MIT
By: Jake Luer, Keith Cirkel, David Losert, Aleksey Shvayka, Lucas Fernandes da Costa, Grant Snodgrass, Jeremy Tice, Edward Betts, dvlsg, Amila Welihinda, Jake Champion, Miroslav Bajtoš
+5 -5
View File
@@ -169,21 +169,16 @@
"dependencies": {
"@types/chai": "catalog:",
"@vitest/mocker": "workspace:*",
"@vitest/pretty-format": "workspace:*",
"@vitest/spy": "workspace:*",
"@vitest/utils": "workspace:*",
"chai": "catalog:",
"es-module-lexer": "^2.0.0",
"expect-type": "^1.3.0",
"magic-string": "catalog:",
"obug": "catalog:",
"pathe": "catalog:",
"picomatch": "^4.0.3",
"std-env": "catalog:",
"tinybench": "catalog:",
"tinyexec": "^1.0.2",
"tinyglobby": "catalog:",
"tinyrainbow": "catalog:",
"why-is-node-running": "^2.3.0"
},
"devDependencies": {
@@ -201,7 +196,10 @@
"@types/picomatch": "^4.0.2",
"@types/prompts": "^2.4.9",
"@vitest/expect": "workspace:*",
"@vitest/pretty-format": "workspace:*",
"@vitest/snapshot": "workspace:*",
"@vitest/spy": "workspace:*",
"@vitest/utils": "workspace:*",
"acorn": "8.11.3",
"acorn-walk": "catalog:",
"birpc": "catalog:",
@@ -211,9 +209,11 @@
"jsdom": "^29.1.1",
"local-pkg": "^1.1.2",
"mime": "^4.1.0",
"pathe": "catalog:",
"prompts": "^2.4.2",
"strip-literal": "catalog:",
"tinyhighlight": "catalog:",
"tinyrainbow": "catalog:",
"vite": "^6.4.0 || ^7.0.0 || ^8.0.0",
"ws": "catalog:"
}
+22 -5
View File
@@ -71,10 +71,6 @@ const external = [
'vitest/optional-types.js',
'vitest/browser',
'vite/module-runner',
'@vitest/utils/diff',
'@vitest/utils/error',
'@vitest/utils/source-map',
/@vitest\/utils\/\w+/,
/@vitest\/mocker\/\w+/,
'#module-evaluator',
@@ -116,6 +112,17 @@ export default ({ watch }) =>
dir: 'dist',
format: 'esm',
chunkFileNames: 'chunks/[name].[hash].js',
manualChunks(id) {
// `tinyrainbow`'s default export is a single mutable color object whose
// `isColorSupported` flag and formatters are toggled at runtime (e.g.
// `disableDefaultColors()`). If it is inlined into several chunks each
// copy has its own object, so disabling colors on one no longer affects
// the others. Pin it to ONE shared chunk so every consumer in a process
// mutates the same instance.
if (/[\\/]tinyrainbow[\\/]/.test(id)) {
return 'tinyrainbow'
}
},
},
external,
moduleContext: (id) => {
@@ -153,7 +160,17 @@ export default ({ watch }) =>
},
watch: false,
external,
plugins: dtsUtils.dts(),
plugins: [
...dtsUtils.dts(),
{
name: 'vitest-bundle-optional-types',
resolveId(source) {
if (source === '@vitest/spy/optional-types.js') {
return 'vitest/optional-runtime-types.js'
}
},
},
],
},
])
+6
View File
@@ -191,6 +191,12 @@ export type {
RunnerTestSuite,
} from './index'
export type { SerializedError } from '@vitest/utils'
// Re-exported from Vitest's own bundled `tinyrainbow` instance. Vitest inlines
// `tinyrainbow` into its dist, so importing the package directly gives a different
// object than the one the reporters use; this export lets programmatic consumers
// (e.g. the test suite) disable ANSI colors on the instance Vitest actually renders
// with.
export { disableDefaultColors } from 'tinyrainbow'
export {
esbuildVersion,
+3 -1
View File
@@ -7,7 +7,6 @@ import { runInThisContext } from 'node:vm'
import * as spyModule from '@vitest/spy'
import { setupChaiConfig } from '../../integrations/chai/config'
import { loadEnvironment } from '../../integrations/env/loader'
import { NativeModuleRunner } from '../../utils/nativeModuleRunner'
import { Traces } from '../../utils/traces'
import { emitModuleRunner } from '../listeners'
import { listenForErrors } from '../moduleRunner/errorCatcher'
@@ -55,6 +54,9 @@ async function startModuleRunner(options: ContextModuleRunnerOptions): Promise<T
spyModule,
})
}
// imported lazily (pulls in `local-pkg`) so it stays out of the default
// worker startup graph; only the `viteModuleRunner: false` path needs it
const { NativeModuleRunner } = await import('../../utils/nativeModuleRunner')
_moduleRunner = new NativeModuleRunner(
root,
mocker,
+15 -18
View File
@@ -1017,18 +1017,9 @@ importers:
'@vitest/mocker':
specifier: workspace:*
version: link:../mocker
'@vitest/pretty-format':
specifier: workspace:*
version: link:../pretty-format
'@vitest/spy':
specifier: workspace:*
version: link:../spy
'@vitest/ui':
specifier: workspace:*
version: link:../ui
'@vitest/utils':
specifier: workspace:*
version: link:../utils
chai:
specifier: 'catalog:'
version: 6.2.2
@@ -1044,9 +1035,6 @@ importers:
obug:
specifier: 'catalog:'
version: 2.1.1
pathe:
specifier: 'catalog:'
version: 2.0.3
picomatch:
specifier: ^4.0.3
version: 4.0.3
@@ -1062,9 +1050,6 @@ importers:
tinyglobby:
specifier: 'catalog:'
version: 0.2.15
tinyrainbow:
specifier: 'catalog:'
version: 3.1.0
why-is-node-running:
specifier: ^2.3.0
version: 2.3.0
@@ -1111,9 +1096,18 @@ importers:
'@vitest/expect':
specifier: workspace:*
version: link:../expect
'@vitest/pretty-format':
specifier: workspace:*
version: link:../pretty-format
'@vitest/snapshot':
specifier: workspace:*
version: link:../snapshot
'@vitest/spy':
specifier: workspace:*
version: link:../spy
'@vitest/utils':
specifier: workspace:*
version: link:../utils
acorn:
specifier: 8.11.3
version: 8.11.3(patch_hash=62f89b815dbd769c8a4d5b19b1f6852f28922ecb581d876c8a8377d05c2483c4)
@@ -1141,6 +1135,9 @@ importers:
mime:
specifier: ^4.1.0
version: 4.1.0
pathe:
specifier: 'catalog:'
version: 2.0.3
prompts:
specifier: ^2.4.2
version: 2.4.2
@@ -1150,6 +1147,9 @@ importers:
tinyhighlight:
specifier: 'catalog:'
version: 0.3.2([email protected])
tinyrainbow:
specifier: 'catalog:'
version: 3.1.0
vite:
specifier: 8.0.11
version: 8.0.11(@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])
@@ -1468,9 +1468,6 @@ importers:
tinyexec:
specifier: ^1.0.2
version: 1.0.2
tinyrainbow:
specifier: 'catalog:'
version: 3.1.0
vite:
specifier: 8.0.11
version: 8.0.11(@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])
+2 -1
View File
@@ -12,7 +12,7 @@ export function createDtsUtils({
/**
* @returns {import('rollup').Plugin[]} plugins
*/
isolatedDecl() {
isolatedDecl(options = {}) {
return [
isolatedDecl({
transformer: 'oxc',
@@ -20,6 +20,7 @@ export function createDtsUtils({
// exclude direct imports to other package sources
include: path.join(process.cwd(), '**/*.ts'),
extraOutdir: isolatedDeclDir,
...options,
}),
{
name: 'isolated-decl-dts-extra',
+5 -4
View File
@@ -19,13 +19,14 @@ import { fileURLToPath, pathToFileURL } from 'node:url'
import { inspect, stripVTControlCharacters } from 'node:util'
import { dirname, relative, resolve } from 'pathe'
import { x } from 'tinyexec'
import * as tinyrainbow from 'tinyrainbow'
import { afterEach, onTestFinished, TestRunner } from 'vitest'
import { Logger, PluginHarness, resolveConfig, startVitest } from 'vitest/node'
import { disableDefaultColors, Logger, PluginHarness, resolveConfig, startVitest } from 'vitest/node'
import { Cli } from './cli'
// override default colors to disable them in tests
Object.assign(tinyrainbow.default, tinyrainbow.getDefaultColors())
// Vitest bundles its own `tinyrainbow` instance (see rollup `manualChunks`), which
// is a different object than the one imported above. Disable colors on it too so
// reporter output captured in tests is deterministic regardless of `CI`/`FORCE_COLOR`.
disableDefaultColors()
export interface VitestRunnerCLIOptions {
std?: 'inherit'
-1
View File
@@ -8,7 +8,6 @@
},
"devDependencies": {
"tinyexec": "^1.0.2",
"tinyrainbow": "catalog:",
"vite": "latest",
"vitest": "workspace:*"
}
+1
View File
@@ -110,6 +110,7 @@ it('exports snapshot', async ({ skip, task }) => {
"createViteLogger": "function",
"createViteServer": "function",
"createVitest": "function",
"disableDefaultColors": "function",
"distDir": "string",
"esbuildVersion": "string",
"escapeTestName": "function",