Skip to content

Commit

Permalink
refactor: use TS project references instead of running tsc multiple t…
Browse files Browse the repository at this point in the history
…imes (#7437)

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

* deduplicate

* dedup

* eliminate --project

* add swc config

* add target
  • Loading branch information
Josh-Cena authored May 17, 2022
1 parent 1bec5f6 commit 7613ecb
Show file tree
Hide file tree
Showing 76 changed files with 233 additions and 145 deletions.
13 changes: 12 additions & 1 deletion jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion packages/create-docusaurus/.npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
__tests__
node_modules

Expand Down
4 changes: 2 additions & 2 deletions packages/create-docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 1 addition & 0 deletions packages/create-docusaurus/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"module": "es2020",
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
Expand Down
7 changes: 4 additions & 3 deletions packages/create-docusaurus/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
2 changes: 1 addition & 1 deletion packages/docusaurus-logger/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__
2 changes: 1 addition & 1 deletion packages/docusaurus-mdx-loader/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__
2 changes: 1 addition & 1 deletion packages/docusaurus-migrate/.npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__

Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-migrate/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"rootDir": "src",
Expand Down
6 changes: 3 additions & 3 deletions packages/docusaurus-migrate/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-client-redirects/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-blog/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-docs/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"types": "src/plugin-content-docs.d.ts",
"scripts": {
"build": "tsc",
"build": "tsc --build",
"watch": "tsc --watch"
},
"publishConfig": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions packages/docusaurus-plugin-content-docs/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions packages/docusaurus-plugin-content-docs/tsconfig.client.json
Original file line number Diff line number Diff line change
@@ -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"]
}
6 changes: 5 additions & 1 deletion packages/docusaurus-plugin-content-docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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__/**"]
}
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-pages/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-debug/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
13 changes: 13 additions & 0 deletions packages/docusaurus-plugin-debug/tsconfig.client.json
Original file line number Diff line number Diff line change
@@ -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"]
}
6 changes: 5 additions & 1 deletion packages/docusaurus-plugin-debug/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-google-analytics/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-google-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"access": "public"
},
"scripts": {
"build": "tsc",
"build": "tsc --build",
"watch": "tsc --watch"
},
"repository": {
Expand Down
13 changes: 13 additions & 0 deletions packages/docusaurus-plugin-google-analytics/tsconfig.client.json
Original file line number Diff line number Diff line change
@@ -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"]
}
6 changes: 5 additions & 1 deletion packages/docusaurus-plugin-google-analytics/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-google-gtag/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-google-gtag/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build": "tsc",
"build": "tsc --build",
"watch": "tsc --watch"
},
"publishConfig": {
Expand Down
13 changes: 13 additions & 0 deletions packages/docusaurus-plugin-google-gtag/tsconfig.client.json
Original file line number Diff line number Diff line change
@@ -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"]
}
6 changes: 5 additions & 1 deletion packages/docusaurus-plugin-google-gtag/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-ideal-image/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__
6 changes: 1 addition & 5 deletions packages/docusaurus-plugin-ideal-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 0 additions & 8 deletions packages/docusaurus-plugin-ideal-image/tsconfig.browser.json

This file was deleted.

13 changes: 13 additions & 0 deletions packages/docusaurus-plugin-ideal-image/tsconfig.client.json
Original file line number Diff line number Diff line change
@@ -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"]
}
9 changes: 7 additions & 2 deletions packages/docusaurus-plugin-ideal-image/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
4 changes: 0 additions & 4 deletions packages/docusaurus-plugin-ideal-image/tsconfig.server.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-pwa/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
copyUntypedFiles.mjs
.tsbuildinfo
.tsbuildinfo*
tsconfig*
__tests__
Loading

0 comments on commit 7613ecb

Please sign in to comment.