From 8b1acb50d1f860ac70087a244a84f60d2ea4098f Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Sat, 28 May 2022 23:52:05 +0800 Subject: [PATCH] fix: make type-checking pass in Yarn PnP (#7521) * fix: make type-checking pass in Yarn PnP * fix * fix? * fix... * almost there * try again * little fix * disable --- .github/workflows/tests-e2e.yml | 15 +++++++++------ packages/docusaurus-mdx-loader/package.json | 1 + packages/docusaurus-mdx-loader/tsconfig.json | 3 ++- .../docusaurus-module-type-aliases/package.json | 5 ++++- .../docusaurus-plugin-content-blog/package.json | 1 + .../docusaurus-plugin-content-docs/package.json | 7 ++++--- .../docusaurus-plugin-content-pages/package.json | 1 + packages/docusaurus-plugin-debug/package.json | 1 + .../package.json | 1 + .../docusaurus-plugin-google-gtag/package.json | 1 + .../docusaurus-plugin-ideal-image/package.json | 1 + packages/docusaurus-plugin-pwa/package.json | 1 + packages/docusaurus-plugin-sitemap/package.json | 1 + packages/docusaurus-preset-classic/package.json | 3 ++- packages/docusaurus-theme-classic/package.json | 6 +++++- packages/docusaurus-theme-common/package.json | 5 +++++ packages/docusaurus-types/package.json | 2 +- packages/docusaurus-utils-common/package.json | 9 +++++++-- packages/docusaurus-utils/package.json | 8 ++++++++ 19 files changed, 56 insertions(+), 16 deletions(-) diff --git a/.github/workflows/tests-e2e.yml b/.github/workflows/tests-e2e.yml index 92b9f5319f84..ef3e2d103474 100644 --- a/.github/workflows/tests-e2e.yml +++ b/.github/workflows/tests-e2e.yml @@ -64,11 +64,6 @@ jobs: matrix: nodeLinker: [pnp, node-modules] variant: [-s, -st] - exclude: - # Running tsc on PnP requires additional installations, which is not - # worthwhile for a simple E2E test - - variant: -st - nodeLinker: pnp steps: - name: Checkout uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3 @@ -98,13 +93,21 @@ jobs: working-directory: ../test-website env: YARN_ENABLE_IMMUTABLE_INSTALLS: false # Yarn berry should create the lockfile, despite CI env + - name: Install missing dependencies + if: matrix.variant == '-st' && matrix.nodeLinker == 'pnp' + run: | + # These dependencies are referenced in the init project, not by our packages + yarn add @docusaurus/theme-classic @docusaurus/types @types/node + yarn config set packageExtensions --json '{ "unified@^9.2.2": { "dependencies": { "@types/unist": "^2.0.6" } } }' + working-directory: ../test-website - name: Start test-website project run: yarn start --no-open working-directory: ../test-website env: E2E_TEST: true - name: Type check - if: matrix.variant == '-st' + # TODO: there're some lingering issues with PnP + tsc. Enable tsc in PnP later. + if: matrix.variant == '-st' && matrix.nodeLinker != 'pnp' run: yarn typecheck working-directory: ../test-website - name: Build test-website project diff --git a/packages/docusaurus-mdx-loader/package.json b/packages/docusaurus-mdx-loader/package.json index 47e40510dafe..1efcee5eaf0e 100644 --- a/packages/docusaurus-mdx-loader/package.json +++ b/packages/docusaurus-mdx-loader/package.json @@ -31,6 +31,7 @@ "remark-emoji": "^2.2.0", "stringify-object": "^3.3.0", "tslib": "^2.4.0", + "unified": "^9.2.2", "unist-util-visit": "^2.0.3", "url-loader": "^4.1.1", "webpack": "^5.72.1" diff --git a/packages/docusaurus-mdx-loader/tsconfig.json b/packages/docusaurus-mdx-loader/tsconfig.json index 7807612b51a5..3cdfe2a88c91 100644 --- a/packages/docusaurus-mdx-loader/tsconfig.json +++ b/packages/docusaurus-mdx-loader/tsconfig.json @@ -8,7 +8,8 @@ "declarationMap": true, "module": "commonjs", "rootDir": "src", - "outDir": "lib" + "outDir": "lib", + "types": [] }, "include": ["src"], "exclude": ["**/__tests__/**"] diff --git a/packages/docusaurus-module-type-aliases/package.json b/packages/docusaurus-module-type-aliases/package.json index 3c9d3d4f2eba..26d08a22247a 100644 --- a/packages/docusaurus-module-type-aliases/package.json +++ b/packages/docusaurus-module-type-aliases/package.json @@ -12,11 +12,14 @@ "directory": "packages/docusaurus-module-type-aliases" }, "dependencies": { + "@docusaurus/react-loadable": "5.5.2", "@docusaurus/types": "2.0.0-beta.21", + "@types/history": "^4.7.11", "@types/react": "*", "@types/react-router-config": "*", "@types/react-router-dom": "*", - "react-helmet-async": "*" + "react-helmet-async": "*", + "react-loadable": "npm:@docusaurus/react-loadable@5.5.2" }, "peerDependencies": { "react": "*", diff --git a/packages/docusaurus-plugin-content-blog/package.json b/packages/docusaurus-plugin-content-blog/package.json index 8f24c3cfc14d..f5bfcff31857 100644 --- a/packages/docusaurus-plugin-content-blog/package.json +++ b/packages/docusaurus-plugin-content-blog/package.json @@ -21,6 +21,7 @@ "@docusaurus/core": "2.0.0-beta.21", "@docusaurus/logger": "2.0.0-beta.21", "@docusaurus/mdx-loader": "2.0.0-beta.21", + "@docusaurus/types": "2.0.0-beta.21", "@docusaurus/utils": "2.0.0-beta.21", "@docusaurus/utils-common": "2.0.0-beta.21", "@docusaurus/utils-validation": "2.0.0-beta.21", diff --git a/packages/docusaurus-plugin-content-docs/package.json b/packages/docusaurus-plugin-content-docs/package.json index b93c676daf14..bc6a154f51b4 100644 --- a/packages/docusaurus-plugin-content-docs/package.json +++ b/packages/docusaurus-plugin-content-docs/package.json @@ -28,8 +28,11 @@ "@docusaurus/core": "2.0.0-beta.21", "@docusaurus/logger": "2.0.0-beta.21", "@docusaurus/mdx-loader": "2.0.0-beta.21", + "@docusaurus/module-type-aliases": "2.0.0-beta.21", + "@docusaurus/types": "2.0.0-beta.21", "@docusaurus/utils": "2.0.0-beta.21", "@docusaurus/utils-validation": "2.0.0-beta.21", + "@types/react-router-config": "^5.0.6", "combine-promises": "^1.1.0", "fs-extra": "^10.1.0", "import-fresh": "^3.3.0", @@ -41,15 +44,13 @@ "webpack": "^5.72.1" }, "devDependencies": { - "@docusaurus/module-type-aliases": "2.0.0-beta.21", "@docusaurus/types": "2.0.0-beta.21", "@types/js-yaml": "^4.0.5", "@types/picomatch": "^2.3.0", "commander": "^5.1.0", "escape-string-regexp": "^4.0.0", "picomatch": "^2.3.1", - "shelljs": "^0.8.5", - "utility-types": "^3.10.0" + "shelljs": "^0.8.5" }, "peerDependencies": { "react": "^16.8.4 || ^17.0.0", diff --git a/packages/docusaurus-plugin-content-pages/package.json b/packages/docusaurus-plugin-content-pages/package.json index 8ea086319ad5..c9167e386d3a 100644 --- a/packages/docusaurus-plugin-content-pages/package.json +++ b/packages/docusaurus-plugin-content-pages/package.json @@ -20,6 +20,7 @@ "dependencies": { "@docusaurus/core": "2.0.0-beta.21", "@docusaurus/mdx-loader": "2.0.0-beta.21", + "@docusaurus/types": "2.0.0-beta.21", "@docusaurus/utils": "2.0.0-beta.21", "@docusaurus/utils-validation": "2.0.0-beta.21", "fs-extra": "^10.1.0", diff --git a/packages/docusaurus-plugin-debug/package.json b/packages/docusaurus-plugin-debug/package.json index 1c67b206460f..d9e1cb136ad8 100644 --- a/packages/docusaurus-plugin-debug/package.json +++ b/packages/docusaurus-plugin-debug/package.json @@ -21,6 +21,7 @@ "license": "MIT", "dependencies": { "@docusaurus/core": "2.0.0-beta.21", + "@docusaurus/types": "2.0.0-beta.21", "@docusaurus/utils": "2.0.0-beta.21", "fs-extra": "^10.1.0", "react-json-view": "^1.21.3", diff --git a/packages/docusaurus-plugin-google-analytics/package.json b/packages/docusaurus-plugin-google-analytics/package.json index f1b6d842bc54..e4247fa62587 100644 --- a/packages/docusaurus-plugin-google-analytics/package.json +++ b/packages/docusaurus-plugin-google-analytics/package.json @@ -19,6 +19,7 @@ "license": "MIT", "dependencies": { "@docusaurus/core": "2.0.0-beta.21", + "@docusaurus/types": "2.0.0-beta.21", "@docusaurus/utils-validation": "2.0.0-beta.21", "tslib": "^2.4.0" }, diff --git a/packages/docusaurus-plugin-google-gtag/package.json b/packages/docusaurus-plugin-google-gtag/package.json index 80456c6ffa89..f00b672e394c 100644 --- a/packages/docusaurus-plugin-google-gtag/package.json +++ b/packages/docusaurus-plugin-google-gtag/package.json @@ -19,6 +19,7 @@ "license": "MIT", "dependencies": { "@docusaurus/core": "2.0.0-beta.21", + "@docusaurus/types": "2.0.0-beta.21", "@docusaurus/utils-validation": "2.0.0-beta.21", "tslib": "^2.4.0" }, diff --git a/packages/docusaurus-plugin-ideal-image/package.json b/packages/docusaurus-plugin-ideal-image/package.json index d653cec6f0e0..cf79146b19ee 100644 --- a/packages/docusaurus-plugin-ideal-image/package.json +++ b/packages/docusaurus-plugin-ideal-image/package.json @@ -24,6 +24,7 @@ "@docusaurus/lqip-loader": "2.0.0-beta.21", "@docusaurus/responsive-loader": "^1.7.0", "@docusaurus/theme-translations": "2.0.0-beta.21", + "@docusaurus/types": "2.0.0-beta.21", "@docusaurus/utils-validation": "2.0.0-beta.21", "@endiliey/react-ideal-image": "^0.0.11", "react-waypoint": "^10.1.0", diff --git a/packages/docusaurus-plugin-pwa/package.json b/packages/docusaurus-plugin-pwa/package.json index 6aa7138c16d8..9048db7d4d0a 100644 --- a/packages/docusaurus-plugin-pwa/package.json +++ b/packages/docusaurus-plugin-pwa/package.json @@ -25,6 +25,7 @@ "@docusaurus/core": "2.0.0-beta.21", "@docusaurus/theme-common": "2.0.0-beta.21", "@docusaurus/theme-translations": "2.0.0-beta.21", + "@docusaurus/types": "2.0.0-beta.21", "@docusaurus/utils": "2.0.0-beta.21", "@docusaurus/utils-validation": "2.0.0-beta.21", "babel-loader": "^8.2.5", diff --git a/packages/docusaurus-plugin-sitemap/package.json b/packages/docusaurus-plugin-sitemap/package.json index e3914972950f..2b9a9430eeae 100644 --- a/packages/docusaurus-plugin-sitemap/package.json +++ b/packages/docusaurus-plugin-sitemap/package.json @@ -20,6 +20,7 @@ "dependencies": { "@docusaurus/core": "2.0.0-beta.21", "@docusaurus/logger": "2.0.0-beta.21", + "@docusaurus/types": "2.0.0-beta.21", "@docusaurus/utils": "2.0.0-beta.21", "@docusaurus/utils-common": "2.0.0-beta.21", "@docusaurus/utils-validation": "2.0.0-beta.21", diff --git a/packages/docusaurus-preset-classic/package.json b/packages/docusaurus-preset-classic/package.json index 9bbd73146a14..7a1cccb25234 100644 --- a/packages/docusaurus-preset-classic/package.json +++ b/packages/docusaurus-preset-classic/package.json @@ -28,7 +28,8 @@ "@docusaurus/plugin-sitemap": "2.0.0-beta.21", "@docusaurus/theme-classic": "2.0.0-beta.21", "@docusaurus/theme-common": "2.0.0-beta.21", - "@docusaurus/theme-search-algolia": "2.0.0-beta.21" + "@docusaurus/theme-search-algolia": "2.0.0-beta.21", + "@docusaurus/types": "2.0.0-beta.21" }, "peerDependencies": { "react": "^16.8.4 || ^17.0.0", diff --git a/packages/docusaurus-theme-classic/package.json b/packages/docusaurus-theme-classic/package.json index 6eba97104c4b..265f41be2a66 100644 --- a/packages/docusaurus-theme-classic/package.json +++ b/packages/docusaurus-theme-classic/package.json @@ -21,11 +21,14 @@ }, "dependencies": { "@docusaurus/core": "2.0.0-beta.21", + "@docusaurus/mdx-loader": "2.0.0-beta.21", + "@docusaurus/module-type-aliases": "2.0.0-beta.21", "@docusaurus/plugin-content-blog": "2.0.0-beta.21", "@docusaurus/plugin-content-docs": "2.0.0-beta.21", "@docusaurus/plugin-content-pages": "2.0.0-beta.21", "@docusaurus/theme-common": "2.0.0-beta.21", "@docusaurus/theme-translations": "2.0.0-beta.21", + "@docusaurus/types": "2.0.0-beta.21", "@docusaurus/utils": "2.0.0-beta.21", "@docusaurus/utils-common": "2.0.0-beta.21", "@docusaurus/utils-validation": "2.0.0-beta.21", @@ -40,7 +43,8 @@ "prismjs": "^1.28.0", "react-router-dom": "^5.3.3", "rtlcss": "^3.5.0", - "tslib": "^2.4.0" + "tslib": "^2.4.0", + "utility-types": "^3.10.0" }, "devDependencies": { "@docusaurus/module-type-aliases": "2.0.0-beta.21", diff --git a/packages/docusaurus-theme-common/package.json b/packages/docusaurus-theme-common/package.json index 8aac5aa0d043..6769b7f0e6f5 100644 --- a/packages/docusaurus-theme-common/package.json +++ b/packages/docusaurus-theme-common/package.json @@ -28,10 +28,15 @@ }, "license": "MIT", "dependencies": { + "@docusaurus/mdx-loader": "2.0.0-beta.21", "@docusaurus/module-type-aliases": "2.0.0-beta.21", "@docusaurus/plugin-content-blog": "2.0.0-beta.21", "@docusaurus/plugin-content-docs": "2.0.0-beta.21", "@docusaurus/plugin-content-pages": "2.0.0-beta.21", + "@docusaurus/utils": "2.0.0-beta.21", + "@types/history": "^4.7.11", + "@types/react": "*", + "@types/react-router-config": "*", "clsx": "^1.1.1", "parse-numeric-range": "^1.3.0", "prism-react-renderer": "^1.3.3", diff --git a/packages/docusaurus-types/package.json b/packages/docusaurus-types/package.json index 56e45bc4afd6..4415cf4a1c37 100644 --- a/packages/docusaurus-types/package.json +++ b/packages/docusaurus-types/package.json @@ -13,8 +13,8 @@ }, "license": "MIT", "dependencies": { + "@types/history": "^4.7.11", "commander": "^5.1.0", - "history": "^4.9.0", "joi": "^17.6.0", "react-helmet-async": "^1.3.0", "utility-types": "^3.10.0", diff --git a/packages/docusaurus-utils-common/package.json b/packages/docusaurus-utils-common/package.json index 52a8a7fdf3d4..50ea22d1d835 100644 --- a/packages/docusaurus-utils-common/package.json +++ b/packages/docusaurus-utils-common/package.json @@ -21,8 +21,13 @@ "dependencies": { "tslib": "^2.4.0" }, - "devDependencies": { - "@docusaurus/types": "2.0.0-beta.21" + "peerDependencies": { + "@docusaurus/types": "*" + }, + "peerDependenciesMeta": { + "@docusaurus/types": { + "optional": true + } }, "engines": { "node": ">=16.14" diff --git a/packages/docusaurus-utils/package.json b/packages/docusaurus-utils/package.json index 4e02766a5e45..f4c1f954d68a 100644 --- a/packages/docusaurus-utils/package.json +++ b/packages/docusaurus-utils/package.json @@ -44,5 +44,13 @@ "@types/micromatch": "^4.0.2", "@types/react-dom": "^18.0.5", "dedent": "^0.7.0" + }, + "peerDependencies": { + "@docusaurus/types": "*" + }, + "peerDependenciesMeta": { + "@docusaurus/types": { + "optional": true + } } }