refactor: use TS project references instead of running tsc multiple times (#7437)

* refactor: use TS project references instead of running tsc multiple times

* deduplicate

* dedup

* eliminate --project

* add swc config

* add target
This commit is contained in:
Joshua Chen 2022-05-17 15:21:44 +08:00 committed by GitHub
parent 1bec5f673a
commit 7613ecb9ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
76 changed files with 233 additions and 145 deletions

View file

@ -43,7 +43,18 @@ export default {
'/packages/docusaurus-utils/src/index.ts',
],
transform: {
'^.+\\.[jt]sx?$': '@swc/jest',
'^.+\\.[jt]sx?$': [
'@swc/jest',
{
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
},
target: 'es2020',
},
},
],
},
errorOnDeprecated: true,
reporters: ['default', 'github-actions'],

View file

@ -1,5 +1,5 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
__tests__
node_modules

View file

@ -13,8 +13,8 @@
},
"scripts": {
"create-docusaurus": "create-docusaurus",
"build": "tsc -p tsconfig.build.json",
"watch": "tsc -p tsconfig.build.json --watch"
"build": "tsc --build",
"watch": "tsc --watch"
},
"bin": "bin/index.js",
"publishConfig": {

View file

@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"module": "es2020",
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",

View file

@ -1,10 +1,11 @@
// For editor typechecking; includes bin
{
"extends": "./tsconfig.build.json",
"extends": "../../tsconfig.json",
"references": [{"path": "./tsconfig.build.json"}],
"compilerOptions": {
"noEmit": true,
"allowJs": true,
"module": "esnext",
"rootDir": "."
},
"include": ["src", "bin"]
"include": ["bin"]
}

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,5 +1,5 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -7,8 +7,8 @@
"node": ">=14"
},
"scripts": {
"build": "tsc -p tsconfig.build.json",
"watch": "tsc -p tsconfig.build.json --watch"
"build": "tsc --build",
"watch": "tsc --watch"
},
"repository": {
"type": "git",

View file

@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"rootDir": "src",

View file

@ -1,11 +1,11 @@
// For editor typechecking; includes bin
{
"extends": "./tsconfig.build.json",
"extends": "../../tsconfig.json",
"references": [{"path": "./tsconfig.build.json"}],
"compilerOptions": {
"noEmit": true,
"module": "esnext",
"allowJs": true,
"rootDir": "."
},
"include": ["src", "bin"]
"include": ["bin"]
}

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -12,7 +12,7 @@
},
"types": "src/plugin-content-docs.d.ts",
"scripts": {
"build": "tsc",
"build": "tsc --build",
"watch": "tsc --watch"
},
"publishConfig": {

View file

@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
/// <reference types="@docusaurus/module-type-aliases" />
declare module '@docusaurus/plugin-content-docs' {
import type {MDXOptions} from '@docusaurus/mdx-loader';
import type {

View file

@ -5,8 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/
/// <reference types="@docusaurus/module-type-aliases" />
import type {BrokenMarkdownLink, Tag} from '@docusaurus/utils';
import type {
VersionMetadata,

View file

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"module": "esnext",
"target": "esnext",
"rootDir": "src",
"outDir": "lib"
},
"include": ["src/client", "src/*.d.ts"]
}

View file

@ -1,9 +1,13 @@
{
"extends": "../../tsconfig.json",
"references": [{"path": "./tsconfig.client.json"}],
"compilerOptions": {
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"module": "commonjs",
"rootDir": "src",
"outDir": "lib"
}
},
"include": ["src"],
"exclude": ["src/client", "**/__tests__/**"]
}

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -5,7 +5,7 @@
"main": "lib/index.js",
"types": "src/plugin-debug.d.ts",
"scripts": {
"build": "tsc && node copyUntypedFiles.mjs",
"build": "tsc --build && node copyUntypedFiles.mjs && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\"",
"watch": "node copyUntypedFiles.mjs && tsc --watch"
},
"publishConfig": {

View file

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"module": "esnext",
"target": "esnext",
"rootDir": "src",
"outDir": "lib"
},
"include": ["src/theme", "src/*.d.ts"]
}

View file

@ -1,9 +1,13 @@
{
"extends": "../../tsconfig.json",
"references": [{"path": "./tsconfig.client.json"}],
"compilerOptions": {
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"module": "commonjs",
"rootDir": "src",
"outDir": "lib"
}
},
"include": ["src"],
"exclude": ["src/theme"]
}

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -8,7 +8,7 @@
"access": "public"
},
"scripts": {
"build": "tsc",
"build": "tsc --build",
"watch": "tsc --watch"
},
"repository": {

View file

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"module": "esnext",
"target": "esnext",
"rootDir": "src",
"outDir": "lib"
},
"include": ["src/analytics.ts", "src/*.d.ts"]
}

View file

@ -1,9 +1,13 @@
{
"extends": "../../tsconfig.json",
"references": [{"path": "./tsconfig.client.json"}],
"compilerOptions": {
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"module": "commonjs",
"rootDir": "src",
"outDir": "lib"
}
},
"include": ["src"],
"exclude": ["src/analytics.ts"]
}

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -5,7 +5,7 @@
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build": "tsc",
"build": "tsc --build",
"watch": "tsc --watch"
},
"publishConfig": {

View file

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"module": "esnext",
"target": "esnext",
"rootDir": "src",
"outDir": "lib"
},
"include": ["src/gtag.ts", "src/options.ts", "src/*.d.ts"]
}

View file

@ -1,9 +1,13 @@
{
"extends": "../../tsconfig.json",
"references": [{"path": "./tsconfig.client.json"}],
"compilerOptions": {
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"module": "commonjs",
"rootDir": "src",
"outDir": "lib"
}
},
"include": ["src"],
"exclude": ["src/gtag.ts"]
}

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -5,11 +5,7 @@
"main": "lib/index.js",
"types": "src/plugin-ideal-image.d.ts",
"scripts": {
"build": "yarn build:server && yarn build:browser && yarn build:copy && yarn build:format",
"build:server": "tsc --project tsconfig.server.json",
"build:browser": "tsc --project tsconfig.browser.json",
"build:copy": "node copyUntypedFiles.mjs",
"build:format": "prettier --config ../../.prettierrc --write \"lib/**/*.js\""
"build": "tsc --build && node copyUntypedFiles.mjs && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\""
},
"publishConfig": {
"access": "public"

View file

@ -1,8 +0,0 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "esnext",
"jsx": "react-native"
},
"include": ["src/theme/", "src/*.d.ts"]
}

View file

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"module": "esnext",
"target": "esnext",
"rootDir": "src",
"outDir": "lib"
},
"include": ["src/theme", "src/*.d.ts"]
}

View file

@ -1,8 +1,13 @@
{
"extends": "../../tsconfig.json",
"references": [{"path": "./tsconfig.client.json"}],
"compilerOptions": {
"lib": ["DOM", "ES2019"],
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"module": "commonjs",
"rootDir": "src",
"outDir": "lib"
}
},
"include": ["src"],
"exclude": ["src/theme"]
}

View file

@ -1,4 +0,0 @@
{
"extends": "./tsconfig.json",
"include": ["src/*.ts"]
}

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -5,10 +5,7 @@
"main": "lib/index.js",
"types": "src/plugin-pwa.d.ts",
"scripts": {
"build": "yarn build:server && yarn build:browser && yarn build:copy",
"build:server": "tsc --project tsconfig.server.json",
"build:browser": "tsc --project tsconfig.browser.json",
"build:copy": "node copyUntypedFiles.mjs"
"build": "tsc --build && node copyUntypedFiles.mjs && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\""
},
"publishConfig": {
"access": "public"

View file

@ -1,13 +0,0 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "esnext",
"jsx": "react-native"
},
"include": [
"src/theme/",
"src/*.d.ts",
"src/registerSw.ts",
"src/renderReloadPopup.tsx"
]
}

View file

@ -0,0 +1,18 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"rootDir": "src",
"outDir": "lib",
"module": "esnext",
"target": "esnext"
},
"include": [
"src/theme/",
"src/*.d.ts",
"src/registerSw.ts",
"src/renderReloadPopup.tsx"
]
}

View file

@ -1,8 +1,12 @@
{
"extends": "../../tsconfig.json",
"references": [{"path": "./tsconfig.client.json"}],
"compilerOptions": {
"lib": ["DOM", "ES2019"],
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"rootDir": "src",
"outDir": "lib"
}
},
"include": ["src"],
"exclude": ["src/theme/", "src/registerSw.ts", "src/renderReloadPopup.tsx"]
}

View file

@ -1,10 +0,0 @@
{
"extends": "./tsconfig.json",
"include": ["src/*.ts"],
"exclude": [
"src/theme/",
"src/*.d.ts",
"src/registerSw.ts",
"src/renderReloadPopup.tsx"
]
}

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,5 +1,5 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -3,8 +3,7 @@
"compilerOptions": {
"lib": ["DOM", "ES2019"],
"module": "esnext",
"noEmit": true,
"jsx": "react-native"
"noEmit": true
},
"include": ["src/"]
}

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -4,6 +4,7 @@
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"module": "esnext",
"target": "esnext",
"sourceMap": true,
"declarationMap": true,
"rootDir": "src",

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -11,11 +11,7 @@
"access": "public"
},
"scripts": {
"build": "yarn build:server && yarn build:client && yarn build:copy && yarn build:format",
"build:server": "tsc --project tsconfig.server.json",
"build:client": "tsc --project tsconfig.client.json",
"build:copy": "node copyUntypedFiles.mjs",
"build:format": "prettier --config ../../.prettierrc --write \"lib/**/*.js\""
"build": "tsc --build && node copyUntypedFiles.mjs && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\""
},
"repository": {
"type": "git",

View file

@ -1,8 +1,13 @@
{
"extends": "./tsconfig.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"rootDir": "src",
"outDir": "lib",
"module": "esnext",
"jsx": "react-native"
"target": "esnext"
},
"include": ["src/theme/", "src/*.d.ts", "src/custom-buble.ts"]
"include": ["src/theme", "src/*.d.ts", "src/custom-buble.ts"]
}

View file

@ -1,9 +1,12 @@
{
"extends": "../../tsconfig.json",
"references": [{"path": "./tsconfig.client.json"}],
"compilerOptions": {
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"rootDir": "src",
"outDir": "lib"
}
},
"include": ["src"],
"exclude": ["src/custom-buble.ts", "src/theme", "**/__tests__/**"]
}

View file

@ -1,5 +0,0 @@
{
"extends": "./tsconfig.json",
"include": ["src/*.ts"],
"exclude": ["src/custom-buble.ts"]
}

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -21,11 +21,7 @@
},
"license": "MIT",
"scripts": {
"build": "yarn build:server && yarn build:client && yarn build:copy && yarn build:format",
"build:server": "tsc --project tsconfig.server.json",
"build:client": "tsc --project tsconfig.client.json",
"build:copy": "node copyUntypedFiles.mjs",
"build:format": "prettier --config ../../.prettierrc --write \"lib/**/*.js\""
"build": "tsc --build && node copyUntypedFiles.mjs && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\""
},
"dependencies": {
"@docsearch/react": "^3.0.0",

View file

@ -1,8 +1,13 @@
{
"extends": "./tsconfig.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"rootDir": "src",
"outDir": "lib",
"module": "esnext",
"jsx": "react-native"
"target": "esnext"
},
"include": ["src/theme/", "src/client/", "src/*.d.ts"]
"include": ["src/theme", "src/client", "src/*.d.ts"]
}

View file

@ -1,8 +1,12 @@
{
"extends": "../../tsconfig.json",
"references": [{"path": "./tsconfig.client.json"}],
"compilerOptions": {
"lib": ["DOM", "ES2019"],
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"rootDir": "src",
"outDir": "lib"
}
},
"include": ["src"],
"exclude": ["src/client", "src/theme", "**/__tests__/**"]
}

View file

@ -1,4 +0,0 @@
{
"extends": "./tsconfig.json",
"include": ["src/*.ts", "src/templates/*.ts"]
}

View file

@ -1,5 +1,5 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -14,8 +14,8 @@
},
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"watch": "tsc -p tsconfig.build.json --watch",
"build": "tsc --build",
"watch": "tsc --watch",
"update": "node ./update.mjs"
},
"dependencies": {

View file

@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"sourceMap": true,

View file

@ -1,10 +1,11 @@
{
"extends": "../../tsconfig.json",
"references": [{"path": "./tsconfig.build.json"}],
"compilerOptions": {
"module": "esnext",
"noEmit": true,
"checkJs": true,
"allowJs": true
},
"include": ["update.mjs", "src"]
"include": ["update.mjs"]
}

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,5 +1,5 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -24,8 +24,8 @@
"docusaurus": "bin/docusaurus.mjs"
},
"scripts": {
"build": "tsc -p tsconfig.server.json && tsc -p tsconfig.client.json && node copyUntypedFiles.mjs",
"watch": "node copyUntypedFiles.mjs && concurrently -n \"server,client\" --kill-others \"tsc -p tsconfig.server.json --watch\" \"tsc -p tsconfig.client.json --watch\""
"build": "tsc --build && node copyUntypedFiles.mjs",
"watch": "node copyUntypedFiles.mjs && tsc --watch"
},
"bugs": {
"url": "https://github.com/facebook/docusaurus/issues"

View file

@ -1,13 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"incremental": true,
"lib": ["DOM", "ES2019"],
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"module": "esnext",
"tsBuildInfoFile": "./lib/client/.tsbuildinfo",
"rootDir": "src/client",
"outDir": "lib/client",
"jsx": "react-native"
"target": "esnext",
"rootDir": "src",
"outDir": "lib"
},
"include": ["src/client", "src/deps.d.ts"]
"include": ["src/client", "src/*.d.ts"]
}

View file

@ -1,10 +1,15 @@
// For editor typechecking; includes bin
{
"extends": "./tsconfig.server.json",
"extends": "../../tsconfig.json",
"references": [
{"path": "./tsconfig.server.json"},
{"path": "./tsconfig.client.json"}
],
"compilerOptions": {
"noEmit": true,
"allowJs": true,
"checkJs": true,
"rootDir": ".",
"module": "esnext"
},
"include": ["src", "bin"]
"include": ["bin"]
}

View file

@ -1,12 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"module": "commonjs",
"rootDir": "src",
"outDir": "lib",
"allowJs": true
"outDir": "lib"
},
"include": ["src"],
"exclude": ["**/__tests__/**/*", "src/client"]
"exclude": ["src/client", "**/__tests__/**"]
}

View file

@ -1,5 +1,5 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -1,5 +1,5 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

View file

@ -6,7 +6,7 @@
"lib": ["ESNext", "DOM"],
"declaration": true,
"declarationMap": false,
"jsx": "react",
"jsx": "react-native",
"importHelpers": true,
"noEmitHelpers": true,
@ -44,5 +44,5 @@
"isolatedModules": true,
"skipLibCheck": true // @types/webpack and webpack/types.d.ts are not the same thing
},
"exclude": ["node_modules", "**/__tests__/**/*", "**/lib/**/*"]
"exclude": ["node_modules", "**/__tests__/**", "**/lib/**/*"]
}