mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
fix: better bundling of types (#1785)
* fix: better bundling of types * chore: fix types clash
This commit is contained in:
parent
de858699f0
commit
6ed32dd382
@ -25,6 +25,7 @@
|
||||
"test:ci": "cross-env CI=true pnpm -r --stream --filter !test-fails --filter !test-browser run test --allowOnly",
|
||||
"test:ci:single-thread": "cross-env CI=true pnpm -r --stream --filter !test-fails run test --allowOnly --no-threads",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"typecheck:why": "tsc --noEmit --explainFiles > explainTypes.txt",
|
||||
"ui:build": "vite build packages/ui",
|
||||
"ui:dev": "vite packages/ui",
|
||||
"ui:test": "npm -C packages/ui run test:run"
|
||||
|
||||
@ -60,7 +60,7 @@ const plugins = [
|
||||
}),
|
||||
]
|
||||
|
||||
export default ({ watch }) => [
|
||||
export default ({ watch }) => defineConfig([
|
||||
{
|
||||
input: entries,
|
||||
output: {
|
||||
@ -107,25 +107,19 @@ export default ({ watch }) => [
|
||||
external,
|
||||
plugins,
|
||||
},
|
||||
...dtsEntries.map((input) => {
|
||||
const _external = external
|
||||
// index is vitest default types export
|
||||
if (!input.includes('index'))
|
||||
_external.push('vitest')
|
||||
|
||||
return defineConfig({
|
||||
input,
|
||||
output: {
|
||||
file: input.replace('src/', 'dist/').replace('.ts', '.d.ts'),
|
||||
format: 'esm',
|
||||
},
|
||||
external: _external,
|
||||
plugins: [
|
||||
dts({ respectExternal: true }),
|
||||
],
|
||||
})
|
||||
}),
|
||||
]
|
||||
{
|
||||
input: dtsEntries,
|
||||
output: {
|
||||
dir: 'dist',
|
||||
entryFileNames: chunk => `${chunk.name.replace('src/', '')}.d.ts`,
|
||||
format: 'esm',
|
||||
},
|
||||
external,
|
||||
plugins: [
|
||||
dts({ respectExternal: true }),
|
||||
],
|
||||
},
|
||||
])
|
||||
|
||||
function licensePlugin() {
|
||||
return license({
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
// rollup dts building will external vitest
|
||||
// so output dts entry using vitest to import internal types
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import type { ResolvedC8Options, UserConfig } from 'vitest'
|
||||
import type { ResolvedC8Options, UserConfig } from './types'
|
||||
|
||||
export const defaultInclude = ['**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
|
||||
export const defaultExclude = ['**/node_modules/**', '**/dist/**', '**/cypress/**', '**/.{idea,git,cache,output,temp}/**']
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"exclude": ["./dist"]
|
||||
}
|
||||
1
shims.d.ts
vendored
1
shims.d.ts
vendored
@ -1,3 +1,2 @@
|
||||
/// <reference path="./packages/vitest/config.d.ts" />
|
||||
/// <reference path="./packages/vitest/globals.d.ts" />
|
||||
/// <reference path="./packages/vitest/importMeta.d.ts" />
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { basename, dirname, join, resolve } from 'pathe'
|
||||
import { defineConfig } from 'vite'
|
||||
import { defineConfig } from 'vitest/config'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
/// <reference types="vitest" />
|
||||
|
||||
import { defineConfig } from 'vite'
|
||||
|
||||
export default defineConfig({
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
/// <reference types="vitest" />
|
||||
|
||||
import { defineConfig } from 'vite'
|
||||
|
||||
export default defineConfig({
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
/// <reference types="vitest" />
|
||||
|
||||
import { defineConfig } from 'vite'
|
||||
|
||||
export default defineConfig({
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { AssertionError } from 'assert'
|
||||
import type { ErrorWithDiff } from '../../../packages/vitest/dist'
|
||||
import type { File, Suite, Task } from '../../../packages/vitest/src/types'
|
||||
import type { ErrorWithDiff, File, Suite, Task } from 'vitest'
|
||||
|
||||
const file: File = {
|
||||
id: '1223128da3',
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
/// <reference types="vitest" />
|
||||
|
||||
import assert from 'assert'
|
||||
import { join } from 'pathe'
|
||||
import { defineConfig } from 'vite'
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
"exclude": [
|
||||
"**/dist/**",
|
||||
"./packages/vitest/dist/**",
|
||||
"./packages/vitest/*.d.ts",
|
||||
"./packages/ui/client/**",
|
||||
"./examples/**/*.*",
|
||||
"./bench/**"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user