feat(nx-cloud): organize workspace caching with improved input/outputs (#10734)

This commit is contained in:
Nathan Walker
2025-04-29 13:25:39 -07:00
committed by GitHub
parent 2ad5daf7f8
commit 61a83a60c9
27 changed files with 2202 additions and 73 deletions

View File

@ -8,6 +8,9 @@ on:
pull_request:
workflow_dispatch:
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
@ -19,10 +22,16 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 23.5.0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v4
with:
main-branch-name: 'main'
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
@ -36,7 +45,7 @@ jobs:
- name: Install NativeScript
run: |
python3 -m pip install --upgrade pip six
npm i -g nativescript --ignore-scripts --legacy-peer-deps
npm i -g nativescript --ignore-scripts
ns usage-reporting disable
ns error-reporting disable
@ -57,4 +66,4 @@ jobs:
with:
api-level: 34
arch: x86_64
script: node tools/scripts/run-automated.js android
script: npx nx test apps-automated -c=android

View File

@ -8,6 +8,9 @@ on:
pull_request:
workflow_dispatch:
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
@ -27,9 +30,14 @@ jobs:
with:
node-version: 23.5.0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v4
with:
main-branch-name: 'main'
- name: Install NativeScript
run: |
npm i -g nativescript --ignore-scripts --legacy-peer-deps
npm i -g nativescript --ignore-scripts
ns usage-reporting disable
ns error-reporting disable
# ns doctor
@ -47,4 +55,4 @@ jobs:
os_version: '17.5'
- name: Run tests on iOS Simulator
run: node tools/scripts/run-automated.js ios
run: npx nx test apps-automated -c=ios

View File

@ -9,6 +9,7 @@ on:
env:
NPM_TAG: 'next'
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
jobs:
release:
@ -20,6 +21,11 @@ jobs:
- name: Setup
run: npm run setup
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v4
with:
main-branch-name: 'main'
- name: Generate Version
working-directory: packages/core
run: |

View File

@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v2
- name: Setup
run: npm install --legacy-peer-deps
run: npm install
- name: Generate Version
run: |

View File

@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v2
- name: Setup
run: npm install --legacy-peer-deps
run: npm install
- name: Generate Version
working-directory: packages/webpack
@ -32,10 +32,10 @@ jobs:
run: npx nx run webpack:build
- name: Publish @nativescript/webpack
working-directory: dist/packages
working-directory: dist/packages/webpack5
env:
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ../../.npmrc
echo "Publishing @nativescript/webpack@$NPM_VERSION to NPM with tag $NPM_TAG..."
npm publish nativescript-webpack.tgz --tag $NPM_TAG --dry-run
npm publish --tag $NPM_TAG --dry-run

View File

@ -1,6 +0,0 @@
legacy-peer-deps=true
# npm 9+ this defaults to `true` meaning `file:` dependencies are packed and then installed
# but since we want to link the source files in this case, we disable this behavior and
# opt to link the dependency as-is instead. (eg. @nativescript/core)
install-links=false

View File

@ -14,7 +14,7 @@
"@nativescript/android": "~8.8.0",
"@nativescript/ios": "~8.8.0",
"@nativescript/visionos": "~8.8.0",
"@nativescript/webpack": "file:../../dist/packages/nativescript-webpack.tgz",
"@nativescript/webpack": "file:../../dist/packages/webpack5",
"circular-dependency-plugin": "^5.2.2",
"typescript": "~5.6.0"
},

View File

@ -11,6 +11,7 @@
"targets": {
"build": {
"executor": "@nativescript/nx:build",
"inputs": ["default", "^production"],
"options": {
"noHmr": true,
"production": true,
@ -18,10 +19,12 @@
"release": true,
"forDevice": true
},
"configurations": {}
"configurations": {},
"dependsOn": ["^build"]
},
"debug": {
"executor": "@nativescript/nx:debug",
"inputs": ["default", "^production"],
"options": {
"noHmr": true,
"debug": false,
@ -30,10 +33,12 @@
"forDevice": false,
"prepare": false
},
"configurations": {}
"configurations": {},
"dependsOn": ["^build"]
},
"prepare": {
"executor": "@nativescript/nx:prepare",
"inputs": ["default", "^production"],
"options": {
"noHmr": true,
"production": true,
@ -42,7 +47,21 @@
"forDevice": true,
"prepare": true
},
"configurations": {}
"configurations": {},
"dependsOn": ["^build"]
},
"test": {
"executor": "nx:run-commands",
"defaultConfiguration": "ios",
"configurations": {
"ios": {
"commands": ["node tools/scripts/run-automated.js ios"]
},
"android": {
"commands": ["node tools/scripts/run-automated.js android"]
}
},
"dependsOn": ["^build"]
},
"clean": {
"executor": "@nativescript/nx:clean",
@ -54,5 +73,6 @@
"lintFilePatterns": ["apps/automated/**/*.ts", "apps/automated/src/**/*.html"]
}
}
}
},
"implicitDependencies": ["webpack5"]
}

View File

@ -1 +0,0 @@
legacy-peer-deps=true

View File

@ -15,7 +15,7 @@
"@nativescript/android": "~8.8.0",
"@nativescript/ios": "~8.8.0",
"@nativescript/visionos": "~8.8.0",
"@nativescript/webpack": "file:../../dist/packages/nativescript-webpack.tgz",
"@nativescript/webpack": "file:../../dist/packages/webpack5",
"typescript": "~5.6.0"
}
}

View File

@ -18,7 +18,8 @@
"release": true,
"forDevice": true
},
"configurations": {}
"configurations": {},
"dependsOn": ["^build"]
},
"debug": {
"executor": "@nativescript/nx:debug",
@ -29,7 +30,8 @@
"forDevice": false,
"prepare": false
},
"configurations": {}
"configurations": {},
"dependsOn": ["^build"]
},
"prepare": {
"executor": "@nativescript/nx:prepare",
@ -41,7 +43,8 @@
"forDevice": true,
"prepare": true
},
"configurations": {}
"configurations": {},
"dependsOn": ["^build"]
},
"clean": {
"executor": "@nativescript/nx:clean",
@ -53,5 +56,6 @@
"lintFilePatterns": ["apps/toolbox/**/*.ts", "apps/toolbox/src/**/*.html"]
}
}
}
},
"implicitDependencies": ["webpack5"]
}

View File

@ -1 +0,0 @@
legacy-peer-deps=true

View File

@ -14,7 +14,7 @@
"@nativescript/android": "~8.8.0",
"@nativescript/ios": "~8.8.0",
"@nativescript/visionos": "~8.8.0",
"@nativescript/webpack": "file:../../dist/packages/nativescript-webpack.tgz",
"@nativescript/webpack": "file:../../dist/packages/webpack5",
"typescript": "~5.6.0"
},
"gitHead": "8ab7726d1ee9991706069c1359c552e67ee0d1a4",

View File

@ -18,7 +18,8 @@
"release": true,
"forDevice": true
},
"configurations": {}
"configurations": {},
"dependsOn": ["^build"]
},
"debug": {
"executor": "@nativescript/nx:debug",
@ -29,7 +30,8 @@
"forDevice": false,
"prepare": false
},
"configurations": {}
"configurations": {},
"dependsOn": ["^build"]
},
"prepare": {
"executor": "@nativescript/nx:prepare",
@ -41,7 +43,8 @@
"forDevice": true,
"prepare": true
},
"configurations": {}
"configurations": {},
"dependsOn": ["^build"]
},
"clean": {
"executor": "@nativescript/nx:clean",
@ -53,5 +56,6 @@
"lintFilePatterns": ["apps/ui/**/*.ts", "apps/ui/src/**/*.html"]
}
}
}
},
"implicitDependencies": ["webpack5"]
}

53
nx.json
View File

@ -69,17 +69,37 @@
},
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"sharedGlobals": ["{workspaceRoot}/workspace.json", "{workspaceRoot}/tsconfig.json", "{workspaceRoot}/nx.json"],
"production": ["default", "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)", "!{projectRoot}/tsconfig.spec.json", "!{projectRoot}/jest.config.[jt]s", "!{projectRoot}/src/test-setup.[jt]s"]
"default": [
"{projectRoot}/**/*",
"sharedGlobals"
],
"sharedGlobals": [
"{workspaceRoot}/workspace.json",
"{workspaceRoot}/tsconfig.json",
"{workspaceRoot}/nx.json"
],
"production": [
"default",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/src/test-setup.[jt]s"
]
},
"targetDefaults": {
"build": {
"inputs": ["production", "^production"],
"inputs": [
"production",
"^production"
],
"cache": true
},
"test": {
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
"inputs": [
"default",
"^production",
"{workspaceRoot}/jest.preset.js"
],
"cache": true
},
"lint": {
@ -95,7 +115,11 @@
"cache": true
},
"@nx/jest:jest": {
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
"inputs": [
"default",
"^production",
"{workspaceRoot}/jest.preset.js"
],
"cache": true,
"options": {
"passWithNoTests": true
@ -109,7 +133,10 @@
},
"@nx/vite:test": {
"cache": true,
"inputs": ["default", "^production"]
"inputs": [
"default",
"^production"
]
}
},
"useDaemonProcess": false,
@ -119,7 +146,12 @@
"useLegacyCache": true,
"release": {
"releaseTagPattern": "{version}-{projectName}",
"projects": ["packages/*", "!packages/ui-mobile-base", "!packages/types-minimal", "!packages/winter-tc"],
"projects": [
"packages/*",
"!packages/ui-mobile-base",
"!packages/types-minimal",
"!packages/winter-tc"
],
"projectsRelationship": "independent",
"changelog": {
"workspaceChangelog": false,
@ -131,5 +163,6 @@
}
}
}
}
}
},
"nxCloudId": "680a89d49c76d63ce41eb397"
}

1994
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
"setup": "npm run clean && npm install",
"setup:yarn": "yarn clean && yarn",
"setup:pnpm": "pnpm run clean && pnpm install",
"postinstall": "ts-patch install && husky && nx run webpack5:build",
"postinstall": "ts-patch install && husky",
"start": "nps"
},
"private": true,
@ -47,33 +47,44 @@
"@typescript-eslint/parser": "^8.6.0",
"@vitest/coverage-v8": "^1.0.4",
"@vitest/ui": "^1.3.1",
"acorn-stage3": "^4.0.0",
"acorn": "^8.7.0",
"copy-webpack-plugin": "^9.0.0",
"copyfiles": "^2.4.0",
"css": "^3.0.0",
"css-tree": "^1.1.2",
"css-what": "^6.1.0",
"dotenv-webpack": "^7.0.0",
"dotenv": "~16.4.0",
"emoji-regex": "^10.3.0",
"enhanced-resolve": "^5.8.3",
"eslint": "~8.57.0",
"eslint-config-prettier": "~9.1.0",
"fork-ts-checker-webpack-plugin": "^7.0.0",
"gonzales": "^1.0.7",
"husky": "^9.0.0",
"jest": "~29.7.0",
"jest-environment-jsdom": "~29.7.0",
"jsdom": "~22.1.0",
"lint-staged": "^15.2.0",
"loader-utils": "^2.0.0 || ^3.0.0",
"module-alias": "^2.2.2",
"nativescript": "~8.9.0",
"nativescript-typedoc-theme": "1.1.0",
"nx": "20.3.0",
"parse-css": "git+https://github.com/tabatkins/parse-css.git",
"parserlib": "^1.1.1",
"postcss": "^8.0.0",
"postcss-import": "^14.0.0",
"postcss-loader": "^7.0.0",
"prettier": "^3.2.5",
"sass": "^1.72.0",
"shady-css-parser": "^0.1.0",
"terser-webpack-plugin": "^5.0.0",
"tree-kill": "^1.2.2",
"ts-dedent": "^2.2.0",
"ts-jest": "29.2.5",
"ts-loader": "^9.0.0",
"ts-node": "10.9.2",
"ts-patch": "^3.0.0",
"tslib": "^2.6.0",
@ -81,6 +92,13 @@
"typescript": "~5.6.0",
"vite": "^5.0.0",
"vitest": "^1.3.1",
"vue-loader": "^15.0.0 <= 15.9.8",
"webpack-bundle-analyzer": "^4.0.0",
"webpack-chain": "^6.0.0",
"webpack-cli": "^4.0.0",
"webpack-merge": "^5.0.0",
"webpack-virtual-modules": "^0.4.0",
"webpack": "^5.30.0 <= 5.50.0 || ^5.51.2",
"zx": "^8.3.0"
},
"lint-staged": {
@ -88,4 +106,4 @@
"npx prettier --write"
]
}
}
}

View File

@ -16,20 +16,51 @@
}
},
"build": {
"executor": "nx:run-commands",
"executor": "@nx/js:tsc",
"inputs": ["default", "^production"],
"outputs": ["{workspaceRoot}/dist/packages"],
"outputs": ["{workspaceRoot}/dist/packages/core"],
"options": {
"commands": [
"npx rimraf dist/packages/core",
"npx tsc -p packages/core/tsconfig.lib.json",
"npx copyfiles \"packages/core/**/*.d.ts\" dist && npx copyfiles \"packages/core/js-libs/**/*\" dist && npx copyfiles \"packages/core/cli-hooks/**/*.js\" dist && npx copyfiles \"packages/core/platforms/**/*\" dist && npx copyfiles \"packages/core/fetch/**/*\" dist && npx copyfiles \"packages/core/css/**/*\" dist && npx copyfiles \"packages/core/css-value/**/*\" dist",
"npx copyfiles -f \"packages/core/package.json\" \"packages/core/README.md\" \"LICENSE\" dist/packages/core",
"cd dist/packages/core && npm pack --pack-destination=.."
],
"cwd": ".",
"parallel": false
}
"tsConfig": "{projectRoot}/tsconfig.lib.json",
"outputPath": "{workspaceRoot}/dist/packages/core",
"rootDir": "{projectRoot}",
"main": "{projectRoot}/index.ts",
"assets": [
"{workspaceRoot}/LICENSE",
"{projectRoot}/README.md",
"{projectRoot}/global-types.d.ts",
{
"glob": "**/*",
"input": "{projectRoot}/js-libs/",
"output": "./js-libs/"
},
{
"glob": "**/*",
"input": "{projectRoot}/cli-hooks/",
"output": "./cli-hooks/"
},
{
"glob": "**/*",
"input": "{projectRoot}/fetch/",
"output": "./fetch/"
},
{
"glob": "**/*",
"input": "{projectRoot}/css/",
"output": "./css/"
},
{
"glob": "**/*",
"input": "{projectRoot}/css-value/",
"output": "./css-value/"
},
{
"glob": "**/*",
"input": "{projectRoot}/platforms/",
"output": "./platforms/"
}
]
},
"dependsOn": ["^build"]
},
"test": {
"executor": "@nx/vite:test",

View File

@ -12,11 +12,10 @@
"sourceMap": true,
"inlineSourceMap": false,
"baseUrl": ".",
"outDir": "../../dist",
"types": ["node"],
"plugins": [
{
"transform": "../webpack5/src/transformers/NativeClass/index.ts",
"transform": "./packages/webpack5/src/transformers/NativeClass/index.ts",
"type": "raw"
}
]

View File

@ -11,7 +11,6 @@
},
"license": "Apache-2.0",
"scripts": {
"build": "tsc --project tsconfig.build.json",
"test": "jest",
"copy-stubs": "mkdirp dist/stubs && cp -R src/stubs/* dist/stubs",
"prepack": "npm run test && npm run build && npm run copy-stubs && chmod +x dist/bin/index.js"

View File

@ -12,10 +12,27 @@
}
},
"build": {
"executor": "nx:run-commands",
"outputs": ["{workspaceRoot}/dist/packages"],
"executor": "@nx/js:tsc",
"inputs": ["default", "^production"],
"outputs": ["{workspaceRoot}/dist/packages/webpack5"],
"options": {
"command": "npx zx ./tools/scripts/pack-webpack5.mjs"
"tsConfig": "{projectRoot}/tsconfig.lib.json",
"outputPath": "{workspaceRoot}/dist/packages/webpack5/dist",
"rootDir": "{projectRoot}/src",
"main": "{projectRoot}/src/index.ts",
"assets": [
{
"input": "{projectRoot}/src/stubs",
"glob": "*.js",
"output": "stubs"
},
{
"input": "{projectRoot}",
"glob": "package.json",
"output": ".."
}
],
"generatePackageJson": false
}
}
}

View File

@ -1,4 +1,4 @@
import type { IWebpackEnv } from '@nativescript/webpack';
import type { IWebpackEnv } from '..';
const ENV_FLAG_RE = /--env\.(\w+)(?:=(.+))?/;

View File

@ -1,4 +1,4 @@
import { defaultConfigs } from '@nativescript/webpack';
import { defaultConfigs } from '..';
import { getAllDependencies } from './dependencies';
import { error } from './log';

View File

@ -1,4 +1,4 @@
import { env } from '@nativescript/webpack';
import { env } from '..';
import dedent from 'ts-dedent';
// de-indents strings so multi-line string literals can be used

View File

@ -4,7 +4,6 @@
"baseUrl": ".",
"target": "es2018",
"module": "commonjs",
"outDir": "./dist",
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,

View File

@ -1,7 +1,4 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src"
},
"include": ["src"]
}

View File

@ -9,21 +9,20 @@ const kill = require('tree-kill');
const path = require('path');
const TIMEOUT_MS = 20 * 60 * 1000; // 20 minutes (is Github CI this slow to boot AVDs?)
const workspaceDir = path.resolve(__dirname, '../..');
const automatedAppPath = path.resolve(__dirname, '../../apps/automated');
const platform = process.argv[2];
const spawned_process = spawn(
"npx",
"ns",
[
"nx",
"debug",
"apps-automated",
platform,
"--no-hmr",
// "--log=trace",
// `--flags="--log=trace"`,
`--timeout=${TIMEOUT_MS}`
],
{
cwd: workspaceDir,
cwd: automatedAppPath,
stdio: ["inherit", "pipe", "pipe"],
}
);