refactor tsconfig setup + migrate to vitest

pull/501/head
Evan You 3 years ago
parent 7f9295261f
commit 17aaaf0180

@ -0,0 +1,18 @@
{
"compilerOptions": {
"baseUrl": ".",
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"noUnusedLocals": true,
"skipLibCheck": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"types": ["node", "vitest/global"],
"paths": {
"node/*": ["../src/node/*"],
"client/*": ["../src/client/*"]
}
},
"include": ["../src", "."]
}

@ -0,0 +1,10 @@
import path from 'path'
export default {
resolve: {
alias: {
node: path.resolve(__dirname, '../src/node'),
client: path.resolve(__dirname, '../src/client')
}
}
}

@ -1,7 +1,7 @@
{ {
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"projectFolder": ".", "projectFolder": "./src/client",
"mainEntryPointFilePath": "./dist/temp/index.d.ts", "mainEntryPointFilePath": "./dist/temp/index.d.ts",

@ -1,7 +1,7 @@
{ {
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"projectFolder": ".", "projectFolder": "./src/node",
"mainEntryPointFilePath": "./dist/temp/index.d.ts", "mainEntryPointFilePath": "./dist/temp/index.d.ts",

@ -1,13 +0,0 @@
module.exports = {
preset: 'ts-jest',
rootDir: __dirname,
moduleNameMapper: {
'^src/(.*)$': '<rootDir>/src/$1',
'^client/(.*)$': '<rootDir>/src/client/$1',
'^node/(.*)$': '<rootDir>/src/node/$1',
'^shared/(.*)$': '<rootDir>/src/shared/$1',
'^tests/(.*)$': '<rootDir>/__tests__/$1'
},
testMatch: ['<rootDir>/__tests__/**/*.spec.ts'],
testPathIgnorePatterns: ['/node_modules/']
}

@ -31,7 +31,7 @@
"lint": "run-s lint:js lint:ts", "lint": "run-s lint:js lint:ts",
"lint:js": "prettier --check --write \"{bin,docs,scripts,src}/**/*.js\"", "lint:js": "prettier --check --write \"{bin,docs,scripts,src}/**/*.js\"",
"lint:ts": "prettier --check --write --parser typescript \"{__tests__,src,docs,types}/**/*.ts\"", "lint:ts": "prettier --check --write --parser typescript \"{__tests__,src,docs,types}/**/*.ts\"",
"test": "jest", "test": "vitest run __tests__ -c __tests__/vitest.config.js --global",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"release": "node scripts/release.js", "release": "node scripts/release.js",
"docs": "run-p dev docs-dev", "docs": "run-p dev docs-dev",
@ -87,7 +87,6 @@
"@types/compression": "^1.7.0", "@types/compression": "^1.7.0",
"@types/debug": "^4.1.7", "@types/debug": "^4.1.7",
"@types/fs-extra": "^9.0.11", "@types/fs-extra": "^9.0.11",
"@types/jest": "^27.0.0",
"@types/koa": "^2.13.1", "@types/koa": "^2.13.1",
"@types/koa-static": "^4.0.1", "@types/koa-static": "^4.0.1",
"@types/lru-cache": "^5.1.0", "@types/lru-cache": "^5.1.0",
@ -109,7 +108,6 @@
"fs-extra": "^10.0.0", "fs-extra": "^10.0.0",
"globby": "^11.0.3", "globby": "^11.0.3",
"gray-matter": "^4.0.3", "gray-matter": "^4.0.3",
"jest": "^27.0.1",
"lint-staged": "^11.0.0", "lint-staged": "^11.0.0",
"lru-cache": "^6.0.0", "lru-cache": "^6.0.0",
"markdown-it": "^12.3.2", "markdown-it": "^12.3.2",
@ -129,8 +127,8 @@
"rollup-plugin-esbuild": "^4.8.2", "rollup-plugin-esbuild": "^4.8.2",
"semver": "^7.3.5", "semver": "^7.3.5",
"sirv": "^1.0.12", "sirv": "^1.0.12",
"ts-jest": "^27.0.1",
"typescript": "^4.3.2", "typescript": "^4.3.2",
"vitest": "^0.1.19",
"yorkie": "^2.0.0" "yorkie": "^2.0.0"
}, },
"pnpm": { "pnpm": {

File diff suppressed because it is too large Load Diff

@ -1,5 +1,5 @@
{ {
"extends": "../../tsconfig.json", "extends": "../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"baseUrl": ".", "baseUrl": ".",
"outDir": "../../dist/client", "outDir": "../../dist/client",

@ -19,6 +19,7 @@ const vueRuntimePath = 'vue/dist/vue.runtime.esm-bundler.js'
export function resolveAliases(root: string, themeDir: string): AliasOptions { export function resolveAliases(root: string, themeDir: string): AliasOptions {
const paths: Record<string, string> = { const paths: Record<string, string> = {
'/@theme': themeDir, '/@theme': themeDir,
'@theme': themeDir,
[SITE_DATA_ID]: SITE_DATA_REQUEST_PATH [SITE_DATA_ID]: SITE_DATA_REQUEST_PATH
} }

@ -1,12 +1,12 @@
{ {
"extends": "../../tsconfig.json", "extends": "../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"target": "es2019", "target": "es2019",
"baseUrl": ".", "baseUrl": ".",
"outDir": "../../dist/node", "outDir": "../../dist/node",
"module": "commonjs", "module": "commonjs",
"lib": ["ESNext", "DOM"], "types": ["node"],
"sourceMap": true "sourceMap": true
}, },
"include": [".", "../../types/shared.d.ts"] "include": ["."]
} }

@ -6,11 +6,12 @@ export type {
HeadConfig, HeadConfig,
LocaleConfig, LocaleConfig,
Header, Header,
DefaultTheme, DefaultTheme
} from '../../types/shared' } from '../../types/shared'
export const EXTERNAL_URL_RE = /^https?:/i export const EXTERNAL_URL_RE = /^https?:/i
// @ts-ignore
export const inBrowser = typeof window !== 'undefined' export const inBrowser = typeof window !== 'undefined'
function findMatchRoot(route: string, roots: string[]): string | undefined { function findMatchRoot(route: string, roots: string[]): string | undefined {

@ -1,7 +1,8 @@
{ {
"extends": "../../tsconfig.json", "extends": "../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"baseUrl": "." "baseUrl": ".",
"lib": ["ESNext", "DOM"]
}, },
"include": ["."] "include": ["."]
} }

@ -0,0 +1,12 @@
{
"compilerOptions": {
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"noUnusedLocals": true,
"skipLibCheck": true,
"esModuleInterop": true,
"lib": ["ESNext"]
},
"include": ["../types/shared.d.ts"]
}

@ -1,26 +0,0 @@
{
"compilerOptions": {
"baseUrl": ".",
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"noUnusedLocals": true,
"skipLibCheck": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"types": ["node", "jest"],
"paths": {
"src/*": ["src/*"],
"client/*": ["src/client/*"],
"node/*": ["src/node/*"],
"shared/*": ["src/shared/*"],
"tests/*": ["__tests__/*"],
"/@shared/*": ["src/client/shared/*"],
"vitepress": ["src/client/index.ts"]
}
},
"include": [
"src",
"__tests__"
]
}
Loading…
Cancel
Save