From 16003eb5a77730f342ed4df684684958c71821d1 Mon Sep 17 00:00:00 2001 From: Nathaniel Tucker Date: Sun, 22 Dec 2024 23:13:42 +0000 Subject: [PATCH] internal: More parallelism for build types (#3325) --- .circleci/config.yml | 71 +++++++++---------- examples/github-app/tsconfig.json | 1 - examples/github-app/tsconfig.typetest.json | 1 + examples/normalizr-relationships/package.json | 14 +--- package.json | 6 +- yarn.lock | 8 --- 6 files changed, 43 insertions(+), 58 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index abd595b8a945..fea8b33ae5ab 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,7 +28,7 @@ jobs: - checkout: depth: 1 - run: - name: examples use local packages + name: Add examples/* to yarn workspace command: | npm pkg set 'workspaces[]'='examples/*' - restore_cache: @@ -46,7 +46,7 @@ jobs: - .yarn/install-state.gz key: v13-dependencies-{{ checksum "yarn.lock" }}-{{ checksum "examples/github-app/package.json" }}-{{ checksum "examples/todo-app/package.json" }} - run: yarn run ci:build:types - - run: yarn run ci:build + - run: yarn run ci:build-test-lib - persist_to_workspace: root: ~/ paths: @@ -69,7 +69,7 @@ jobs: lint: executor: node - resource_class: medium+ + resource_class: medium steps: - attach_workspace: at: ~/ @@ -127,6 +127,7 @@ jobs: parameters: node-version: type: string + executor: node docker: - image: cimg/node:<< parameters.node-version >> steps: @@ -140,16 +141,20 @@ jobs: command: | ANANSI_JEST_TYPECHECK=false npm test --ci --maxWorkers=2 --selectProjects Node - non-app-examples: + setup-esmodule-types: executor: node - resource_class: small + resource_class: large steps: - attach_workspace: at: ~/ - run: - command: | - cd examples/normalizr-relationships - yarn run start + name: Build Legacy Types + command: yarn run ci:build:legacy-types + - persist_to_workspace: + root: ~/ + paths: + # explicitly list so we can ignore some directories that are not needed + - project/packages/*/ts* esmodule-types: parameters: @@ -162,30 +167,26 @@ jobs: - run: name: Install TypeScript Version command: | - if [ "<< parameters.typescript-version >>" != "latest" ]; then - yarn up typescript@~<< parameters.typescript-version >> - fi + yarn up typescript@~<< parameters.typescript-version >> if [[ "<< parameters.typescript-version >>" == "4.0" || \ "<< parameters.typescript-version >>" == "4.1" || \ "<< parameters.typescript-version >>" == "4.3" ]]; then - sed -i '/"@types\/react":/d' package.json - sed -i '/"@types\/react-dom":/d' package.json yarn up @types/react@ts<< parameters.typescript-version >> fi - run: name: Run Typecheck command: | - if [ "<< parameters.typescript-version >>" == "latest" ] || [ "<< parameters.typescript-version >>" == "5.3" ] || [ "<< parameters.typescript-version >>" == "4.8" ]; then + if [ "<< parameters.typescript-version >>" == "5.3" ] || [ "<< parameters.typescript-version >>" == "4.8" ]; then yarn run tsc --project examples/todo-app/tsconfig.json yarn run tsc --project examples/github-app/tsconfig.json fi - yarn run tsc --project examples/todo-app/tsconfig.typetest.json - yarn run tsc --project examples/github-app/tsconfig.typetest.json if [ "<< parameters.typescript-version >>" != "4.0" ]; then yarn run tsc --project examples/todo-app/tsconfig.typetest41.json fi + yarn run tsc --project examples/todo-app/tsconfig.typetest.json + yarn run tsc --project examples/github-app/tsconfig.typetest.json - esmodule-loosenulltypes: + esmodule-types-latest: executor: node steps: - attach_workspace: @@ -193,20 +194,16 @@ jobs: - run: name: Run Typecheck command: | + yarn run tsc --project examples/todo-app/tsconfig.json + yarn run tsc --project examples/github-app/tsconfig.json + yarn run tsc --project examples/todo-app/tsconfig.typetest.json + yarn run tsc --project examples/github-app/tsconfig.typetest.json + yarn run tsc --project examples/todo-app/tsconfig.typetest41.json yarn run tsc --project examples/todo-app/tsconfig.json --strictNullChecks false yarn run tsc --project examples/github-app/tsconfig.json --strictNullChecks false yarn run tsc --project examples/todo-app/tsconfig.typetest.json --strictNullChecks false yarn run tsc --project examples/github-app/tsconfig.typetest.json --strictNullChecks false yarn run tsc --project examples/todo-app/tsconfig.typetest41.json --strictNullChecks false - - esmodule-exactOptionalPropertyTypes: - executor: node - steps: - - attach_workspace: - at: ~/ - - run: - name: Run Typecheck - command: | yarn run tsc --project examples/todo-app/tsconfig.typetest.json --exactOptionalPropertyTypes true yarn run tsc --project examples/github-app/tsconfig.typetest.json --exactOptionalPropertyTypes true yarn run tsc --project examples/todo-app/tsconfig.typetest41.json --exactOptionalPropertyTypes true @@ -216,10 +213,15 @@ jobs: steps: - attach_workspace: at: ~/ + - run: yarn run ci:build:esmodule - run: command: | cd examples/todo-app npm run build:browser -- --env readable + - run: + command: | + cd examples/normalizr-relationships + yarn run start workflows: version: 2 @@ -244,10 +246,13 @@ workflows: - typecheck: requires: - setup - - non-app-examples: + - validate-esmodule-browser-build: requires: - setup - - validate-esmodule-browser-build: + - esmodule-types-latest: + requires: + - setup + - setup-esmodule-types: requires: - setup - esmodule-types: @@ -258,12 +263,6 @@ workflows: # 4.1 is min version for rest package working well # 4.3 # 4.7 (but its broken so we do 4.8) lets you apply a generic type to a function type to see its return value - typescript-version: ["4.0", "4.1", "4.3", "4.8", "5.3", "latest"] + typescript-version: ["4.0", "4.1", "4.3", "4.8", "5.3"] requires: - - setup - - esmodule-loosenulltypes: - requires: - - setup - - esmodule-exactOptionalPropertyTypes: - requires: - - setup + - setup-esmodule-types diff --git a/examples/github-app/tsconfig.json b/examples/github-app/tsconfig.json index 80def36e93cc..5e14e38ea0cc 100644 --- a/examples/github-app/tsconfig.json +++ b/examples/github-app/tsconfig.json @@ -14,7 +14,6 @@ "esModuleInterop": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, - "types": ["@anansi/webpack-config/types","./src/types/remark-remove-comments"], "paths": { "@/*": ["./src/*"], diff --git a/examples/github-app/tsconfig.typetest.json b/examples/github-app/tsconfig.typetest.json index 1225a13cc3b7..64312ac0675e 100644 --- a/examples/github-app/tsconfig.typetest.json +++ b/examples/github-app/tsconfig.typetest.json @@ -2,6 +2,7 @@ "extends": "./tsconfig", "compilerOptions": { "skipLibCheck": true, + "skipDefaultLibCheck": true }, "include": ["typetest.ts"], } diff --git a/examples/normalizr-relationships/package.json b/examples/normalizr-relationships/package.json index b0869f5dd1a9..6f8a3413d52d 100644 --- a/examples/normalizr-relationships/package.json +++ b/examples/normalizr-relationships/package.json @@ -12,19 +12,11 @@ "devDependencies": { "@babel/core": "7.26.0", "@babel/node": "7.26.0", - "@types/babel__core": "^7", - "mockdate": "^3.0.5", - "rollup": "2.79.2", - "rollup-plugin-babel": "^4.4.0", - "rollup-plugin-commonjs": "^10.1.0", - "rollup-plugin-filesize": "^9.1.2", - "rollup-plugin-json": "^4.0.0", - "rollup-plugin-node-resolve": "^5.2.0", - "rollup-plugin-replace": "^2.2.0", - "rollup-plugin-terser": "^7.0.2" + "@types/babel__core": "^7" }, "dependencies": { "@data-client/endpoint": "workspace:^", - "@data-client/normalizr": "workspace:^" + "@data-client/normalizr": "workspace:^", + "mockdate": "^3.0.5" } } diff --git a/package.json b/package.json index 73f799a53e43..a587fa629568 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,10 @@ "build:bundle": "yarn workspaces foreach -Wptiv --no-private run build:bundle", "build:clean": "yarn workspaces foreach -Wpti --no-private run build:clean", "build:types": "yarn build:copy:ambient && tsc --build && yarn workspaces foreach -Wpti --no-private run build:legacy-types", - "ci:build:types": "yarn build:copy:ambient && tsc --build && yarn workspaces foreach -WptivR --from @data-client/react --from @data-client/rest --from @data-client/graphql run build:legacy-types", - "ci:build": "yarn workspaces foreach -WptivR --from @data-client/react --from @data-client/rest --from @data-client/graphql --from @data-client/test run build:lib && yarn workspace @data-client/test run build:bundle && yarn workspace @data-client/normalizr run build:js:node && yarn workspace @data-client/endpoint run build:js:node", + "ci:build:types": "yarn build:copy:ambient && tsc --build", + "ci:build:legacy-types": "yarn workspaces foreach -WptivR -j 10 --from @data-client/react --from @data-client/rest --from @data-client/graphql run build:legacy-types", + "ci:build-test-lib": "yarn workspace @data-client/test run build:lib && yarn workspace @data-client/test run build:bundle", + "ci:build:esmodule": "yarn workspaces foreach -WptivR --from @data-client/react --from @data-client/rest --from @data-client/graphql run build:lib && yarn workspace @data-client/normalizr run build:js:node && yarn workspace @data-client/endpoint run build:js:node", "build:copy:ambient": "mkdirp ./packages/endpoint/lib && copyfiles --flat ./packages/endpoint/src/schema.d.ts ./packages/endpoint/lib/ && copyfiles --flat ./packages/endpoint/src/endpoint.d.ts ./packages/endpoint/lib/ && mkdirp ./packages/rest/lib && copyfiles --flat ./packages/rest/src/RestEndpoint.d.ts ./packages/rest/lib && copyfiles --flat ./packages/rest/src/next/RestEndpoint.d.ts ./packages/rest/lib/next && mkdirp ./packages/react/lib && copyfiles --flat ./packages/react/src/server/redux/redux.d.ts ./packages/react/lib/server/redux", "copy:websitetypes": "./scripts/copywebsitetypes.sh", "test": "NODE_ENV=test NODE_OPTIONS=--experimental-vm-modules jest", diff --git a/yarn.lock b/yarn.lock index 1126b29b519f..da9d5fefd35c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -21795,14 +21795,6 @@ __metadata: "@data-client/normalizr": "workspace:^" "@types/babel__core": "npm:^7" mockdate: "npm:^3.0.5" - rollup: "npm:2.79.2" - rollup-plugin-babel: "npm:^4.4.0" - rollup-plugin-commonjs: "npm:^10.1.0" - rollup-plugin-filesize: "npm:^9.1.2" - rollup-plugin-json: "npm:^4.0.0" - rollup-plugin-node-resolve: "npm:^5.2.0" - rollup-plugin-replace: "npm:^2.2.0" - rollup-plugin-terser: "npm:^7.0.2" languageName: unknown linkType: soft