diff --git a/.changeset/twelve-buses-prove.md b/.changeset/twelve-buses-prove.md new file mode 100644 index 000000000..4a1875a1b --- /dev/null +++ b/.changeset/twelve-buses-prove.md @@ -0,0 +1,45 @@ +--- +"@rnx-kit/metro-plugin-cyclic-dependencies-detector": major +"@rnx-kit/react-native-error-trace-decorator": major +"@rnx-kit/esbuild-plugin-import-path-remapper": major +"@rnx-kit/babel-plugin-import-path-remapper": major +"@rnx-kit/babel-preset-metro-react-native": major +"@rnx-kit/metro-plugin-duplicates-checker": major +"@rnx-kit/react-native-test-app-msal": major +"@rnx-kit/react-native-lazy-index": major +"@rnx-kit/third-party-notices": major +"@rnx-kit/tools-react-native": major +"@rnx-kit/typescript-service": major +"@rnx-kit/commitlint-lite": major +"@rnx-kit/metro-serializer": major +"@rnx-kit/tools-language": major +"@rnx-kit/metro-service": major +"@rnx-kit/metro-config": major +"@rnx-kit/bundle-diff": major +"@rnx-kit/align-deps": major +"@rnx-kit/tools-node": major +"@rnx-kit/tsconfig": major +"@rnx-kit/console": major +"@react-native-webapis/battery-status": minor +"@react-native-webapis/web-storage": minor +"@rnx-kit/esbuild-bundle-analyzer": minor +"@rnx-kit/metro-serializer-esbuild": minor +"@rnx-kit/rn-changelog-generator": minor +"@rnx-kit/metro-plugin-typescript": minor +"@rnx-kit/metro-resolver-symlinks": minor +"@rnx-kit/react-native-auth": minor +"@rnx-kit/react-native-host": minor +"@rnx-kit/patcher-rnmacos": minor +"@rnx-kit/tools-filesystem": minor +"@rnx-kit/tools-workspaces": minor +"@rnx-kit/eslint-plugin": minor +"@rnx-kit/tools-android": minor +"@rnx-kit/tools-windows": minor +"@rnx-kit/jest-preset": minor +"@rnx-kit/tools-apple": minor +"@rnx-kit/tools-shell": minor +"@rnx-kit/polyfills": minor +"@rnx-kit/config": minor +--- + +Bump minimum Node version to 16.17 diff --git a/incubator/@react-native-webapis/battery-status/package.json b/incubator/@react-native-webapis/battery-status/package.json index 001f9d652..eba5a6618 100644 --- a/incubator/@react-native-webapis/battery-status/package.json +++ b/incubator/@react-native-webapis/battery-status/package.json @@ -26,9 +26,6 @@ "url": "https://github.com/microsoft/rnx-kit", "directory": "incubator/@react-native-webapis/battery-status" }, - "engines": { - "node": ">=14.15" - }, "scripts": { "build": "rnx-kit-scripts build", "format": "rnx-kit-scripts format", @@ -53,5 +50,8 @@ "react-native": "^0.75.0", "typescript": "^5.0.0" }, + "engines": { + "node": ">=16.17" + }, "experimental": true } diff --git a/incubator/@react-native-webapis/battery-status/tsconfig.json b/incubator/@react-native-webapis/battery-status/tsconfig.json index 179a9ad24..a703824fa 100644 --- a/incubator/@react-native-webapis/battery-status/tsconfig.json +++ b/incubator/@react-native-webapis/battery-status/tsconfig.json @@ -1,4 +1,7 @@ { "extends": "@rnx-kit/tsconfig/tsconfig.json", + "compilerOptions": { + "lib": ["ES2021", "DOM"] + }, "include": ["src"] } diff --git a/incubator/@react-native-webapis/web-storage/tsconfig.json b/incubator/@react-native-webapis/web-storage/tsconfig.json index 179a9ad24..a703824fa 100644 --- a/incubator/@react-native-webapis/web-storage/tsconfig.json +++ b/incubator/@react-native-webapis/web-storage/tsconfig.json @@ -1,4 +1,7 @@ { "extends": "@rnx-kit/tsconfig/tsconfig.json", + "compilerOptions": { + "lib": ["ES2021", "DOM"] + }, "include": ["src"] } diff --git a/incubator/build-plugin-firebase/package.json b/incubator/build-plugin-firebase/package.json index ab25de62f..3bcf20276 100644 --- a/incubator/build-plugin-firebase/package.json +++ b/incubator/build-plugin-firebase/package.json @@ -44,5 +44,8 @@ "prettier": "^3.0.0", "typescript": "^5.0.0" }, + "engines": { + "node": ">=18.12" + }, "experimental": true } diff --git a/incubator/commitlint-lite/package.json b/incubator/commitlint-lite/package.json index ce4873fab..f41cfcfce 100644 --- a/incubator/commitlint-lite/package.json +++ b/incubator/commitlint-lite/package.json @@ -42,7 +42,7 @@ "typescript": "^5.0.0" }, "engines": { - "node": ">=14.18" + "node": ">=16.17" }, "experimental": true } diff --git a/incubator/esbuild-bundle-analyzer/package.json b/incubator/esbuild-bundle-analyzer/package.json index c6628aab7..c38525b05 100644 --- a/incubator/esbuild-bundle-analyzer/package.json +++ b/incubator/esbuild-bundle-analyzer/package.json @@ -22,9 +22,6 @@ "url": "https://github.com/microsoft/rnx-kit", "directory": "incubator/esbuild-bundle-analyzer" }, - "engines": { - "node": ">=14.15" - }, "scripts": { "prepare": "echo '⚠️ esbuild-bundle-analyzer is EXPERIMENTAL - USE WITH CAUTION ⚠️'", "build": "rnx-kit-scripts build", @@ -53,6 +50,9 @@ "prettier": "^3.0.0", "typescript": "^5.0.0" }, + "engines": { + "node": ">=16.17" + }, "jest": { "preset": "@rnx-kit/jest-preset/private" }, diff --git a/incubator/ignore/package.json b/incubator/ignore/package.json index c33f1ff5b..282b51f1f 100644 --- a/incubator/ignore/package.json +++ b/incubator/ignore/package.json @@ -17,5 +17,8 @@ "type": "git", "url": "https://github.com/microsoft/rnx-kit", "directory": "incubator/ignore" + }, + "engines": { + "node": ">=16.17" } } diff --git a/incubator/patcher-rnmacos/package.json b/incubator/patcher-rnmacos/package.json index 9135c48a4..9c5d39a13 100644 --- a/incubator/patcher-rnmacos/package.json +++ b/incubator/patcher-rnmacos/package.json @@ -21,9 +21,6 @@ "url": "https://github.com/microsoft/rnx-kit", "directory": "incubator/patcher-rnmacos" }, - "engines": { - "node": ">=14.15" - }, "scripts": { "prepare": "echo '⚠️ patcher-rnmacos is EXPERIMENTAL - USE WITH CAUTION ⚠️'", "build": "rnx-kit-scripts build", @@ -50,6 +47,9 @@ "istextorbinary": "^3.3.0", "winston": "^3.2.1" }, + "engines": { + "node": ">=16.17" + }, "jest": { "preset": "@rnx-kit/jest-preset/private" } diff --git a/incubator/polyfills/package.json b/incubator/polyfills/package.json index 7c46fda6a..98a087539 100644 --- a/incubator/polyfills/package.json +++ b/incubator/polyfills/package.json @@ -19,9 +19,6 @@ "url": "https://github.com/microsoft/rnx-kit", "directory": "incubator/polyfills" }, - "engines": { - "node": ">=14.15" - }, "scripts": { "build": "rnx-kit-scripts build", "format": "rnx-kit-scripts format", @@ -56,6 +53,9 @@ "prettier": "^3.0.0", "typescript": "^5.0.0" }, + "engines": { + "node": ">=16.17" + }, "rnx-kit": { "alignDeps": { "requirements": { diff --git a/incubator/react-native-error-trace-decorator/package.json b/incubator/react-native-error-trace-decorator/package.json index 5c969c0b7..2f67198e2 100644 --- a/incubator/react-native-error-trace-decorator/package.json +++ b/incubator/react-native-error-trace-decorator/package.json @@ -20,9 +20,6 @@ "url": "https://github.com/microsoft/rnx-kit", "directory": "incubator/react-native-error-trace-decorator" }, - "engines": { - "node": ">=14.15" - }, "scripts": { "build": "rnx-kit-scripts build", "format": "rnx-kit-scripts format", @@ -47,6 +44,9 @@ "source-map": "^0.5.6", "yargs": "^16.0.0" }, + "engines": { + "node": ">=16.17" + }, "jest": { "preset": "@rnx-kit/jest-preset/private" }, diff --git a/incubator/react-native-test-app-msal/package.json b/incubator/react-native-test-app-msal/package.json index e2104025d..c4dcb53eb 100644 --- a/incubator/react-native-test-app-msal/package.json +++ b/incubator/react-native-test-app-msal/package.json @@ -34,5 +34,8 @@ "@rnx-kit/react-native-auth": { "optional": true } + }, + "engines": { + "node": ">=16.17" } } diff --git a/incubator/rn-changelog-generator/package.json b/incubator/rn-changelog-generator/package.json index 5ac7390ec..f00b35879 100644 --- a/incubator/rn-changelog-generator/package.json +++ b/incubator/rn-changelog-generator/package.json @@ -21,9 +21,6 @@ "url": "https://github.com/microsoft/rnx-kit", "directory": "incubator/rn-changelog-generator" }, - "engines": { - "node": ">=14.15" - }, "scripts": { "prepare": "echo '⚠️ rn-changelog-generator is EXPERIMENTAL - USE WITH CAUTION ⚠️'", "build": "rnx-kit-scripts build", @@ -49,6 +46,9 @@ "typescript": "^5.0.0", "yargs": "^16.0.0" }, + "engines": { + "node": ">=16.17" + }, "jest": { "preset": "@rnx-kit/jest-preset/private" } diff --git a/packages/align-deps/package.json b/packages/align-deps/package.json index 3eaf27358..bd2f9d6cb 100644 --- a/packages/align-deps/package.json +++ b/packages/align-deps/package.json @@ -58,7 +58,7 @@ "yargs": "^16.0.0" }, "engines": { - "node": ">=12.13" + "node": ">=16.17" }, "jest": { "preset": "@rnx-kit/jest-preset/private" diff --git a/packages/babel-plugin-import-path-remapper/package.json b/packages/babel-plugin-import-path-remapper/package.json index f75cb5b37..d56bcd6d1 100644 --- a/packages/babel-plugin-import-path-remapper/package.json +++ b/packages/babel-plugin-import-path-remapper/package.json @@ -38,5 +38,8 @@ "eslint": "^8.56.0", "prettier": "^3.0.0", "typescript": "^5.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/babel-preset-metro-react-native/package.json b/packages/babel-preset-metro-react-native/package.json index c3287612f..9d4302e67 100644 --- a/packages/babel-preset-metro-react-native/package.json +++ b/packages/babel-preset-metro-react-native/package.json @@ -63,6 +63,9 @@ "prettier": "^3.0.0", "typescript": "^5.0.0" }, + "engines": { + "node": ">=16.17" + }, "depcheck": { "ignoreMatches": [ "@babel/plugin-transform-classes", diff --git a/packages/bundle-diff/package.json b/packages/bundle-diff/package.json index fd3ef20cf..3f6c8d12f 100644 --- a/packages/bundle-diff/package.json +++ b/packages/bundle-diff/package.json @@ -36,5 +36,8 @@ "eslint": "^8.56.0", "prettier": "^3.0.0", "typescript": "^5.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/config/package.json b/packages/config/package.json index 1203cfaac..0d88f2888 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -54,5 +54,8 @@ "metro": "^0.80.3", "prettier": "^3.0.0", "typescript": "^5.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/console/package.json b/packages/console/package.json index 0c7dbc21f..4cff6e464 100644 --- a/packages/console/package.json +++ b/packages/console/package.json @@ -42,5 +42,8 @@ "eslint": "^8.56.0", "prettier": "^3.0.0", "typescript": "^5.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/esbuild-plugin-import-path-remapper/package.json b/packages/esbuild-plugin-import-path-remapper/package.json index 8a3b36282..2b490e68f 100644 --- a/packages/esbuild-plugin-import-path-remapper/package.json +++ b/packages/esbuild-plugin-import-path-remapper/package.json @@ -37,6 +37,9 @@ "prettier": "^3.0.0", "typescript": "^5.0.0" }, + "engines": { + "node": ">=16.17" + }, "depcheck": { "ignorePatterns": [ "/test/__fixtures__/*" diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index 559732aa8..95e83065a 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -31,5 +31,8 @@ }, "devDependencies": { "prettier": "^3.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index b9328d877..6c3b11198 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -75,7 +75,7 @@ "typescript": "^5.0.0" }, "engines": { - "node": ">=12.13" + "node": ">=16.17" }, "depcheck": { "ignoreMatches": [ diff --git a/packages/jest-preset/package.json b/packages/jest-preset/package.json index 755aa5d17..4a4576f51 100644 --- a/packages/jest-preset/package.json +++ b/packages/jest-preset/package.json @@ -64,6 +64,9 @@ "react" ] }, + "engines": { + "node": ">=16.17" + }, "jest": { "preset": "./private/jest-preset.js" } diff --git a/packages/metro-config/package.json b/packages/metro-config/package.json index b5f3ac455..4ddb09dc3 100644 --- a/packages/metro-config/package.json +++ b/packages/metro-config/package.json @@ -56,6 +56,9 @@ "type-fest": "^4.0.0", "typescript": "^5.0.0" }, + "engines": { + "node": ">=16.17" + }, "depcheck": { "ignoreMatches": [ "@babel/core", diff --git a/packages/metro-config/src/assetPluginForMonorepos.js b/packages/metro-config/src/assetPluginForMonorepos.js index 1d7f9ec03..eb7ba5d34 100644 --- a/packages/metro-config/src/assetPluginForMonorepos.js +++ b/packages/metro-config/src/assetPluginForMonorepos.js @@ -22,8 +22,8 @@ * @returns {AssetData} */ function assetPlugin(assetData) { - assetData.httpServerLocation = assetData.httpServerLocation.replace( - /\.\.\//g, + assetData.httpServerLocation = assetData.httpServerLocation.replaceAll( + "../", "@@/" ); return assetData; @@ -66,7 +66,7 @@ function enhanceMiddleware(middleware, server) { return (req, res, next) => { const { url } = req; if (url && url.startsWith("/assets/")) { - req.url = url.replace(/@@\//g, "../"); + req.url = url.replaceAll("@@/", "../"); } // @ts-ignore Type differs depending on Node version return middleware(req, res, next); diff --git a/packages/metro-config/src/index.js b/packages/metro-config/src/index.js index 1097695fc..a7fd0bc6a 100644 --- a/packages/metro-config/src/index.js +++ b/packages/metro-config/src/index.js @@ -108,7 +108,9 @@ function resolveUniqueModule(packageName, searchStartDir) { // - path/to/node_modules/prop-types const owningDir = path.dirname(result.slice(0, -packageName.length)); const escapedPath = owningDir.replace(/[+.\\]/g, "\\$&"); - const escapedPackageName = path.normalize(packageName).replace(/\\/g, "\\\\"); + const escapedPackageName = path + .normalize(packageName) + .replaceAll("\\", "\\\\"); const exclusionRE = new RegExp( `(? { /__fixtures__[/\\]awesome-repo[/\\]packages[/\\]t-800$/, ]; const folders = defaultWatchFolders() - .map((path) => path.replace(/\\/g, "/")) + .map((path) => path.replaceAll("\\", "/")) .sort(); for (let i = 0; i < folders.length; ++i) { diff --git a/packages/metro-plugin-cyclic-dependencies-detector/package.json b/packages/metro-plugin-cyclic-dependencies-detector/package.json index bb3d96302..4e9d16a15 100644 --- a/packages/metro-plugin-cyclic-dependencies-detector/package.json +++ b/packages/metro-plugin-cyclic-dependencies-detector/package.json @@ -39,5 +39,8 @@ "metro": "^0.80.3", "prettier": "^3.0.0", "typescript": "^5.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/metro-plugin-duplicates-checker/package.json b/packages/metro-plugin-duplicates-checker/package.json index a6e7bc59a..fc9fb48ae 100644 --- a/packages/metro-plugin-duplicates-checker/package.json +++ b/packages/metro-plugin-duplicates-checker/package.json @@ -48,6 +48,9 @@ "prettier": "^3.0.0", "typescript": "^5.0.0" }, + "engines": { + "node": ">=16.17" + }, "jest": { "preset": "@rnx-kit/jest-preset/private" } diff --git a/packages/metro-plugin-duplicates-checker/src/gatherModules.ts b/packages/metro-plugin-duplicates-checker/src/gatherModules.ts index db6aa1ded..7eef0022b 100644 --- a/packages/metro-plugin-duplicates-checker/src/gatherModules.ts +++ b/packages/metro-plugin-duplicates-checker/src/gatherModules.ts @@ -17,7 +17,7 @@ type ModuleInfo = { export type ModuleMap = Record>>; export function normalizePath(p: string): string { - return p.replace(/webpack:\/\/\//g, "").replace(/[\\]+/g, "/"); + return p.replaceAll("webpack:///", "").replace(/[\\]+/g, "/"); } export function resolveModule(source: string): ModuleInfo { diff --git a/packages/metro-plugin-typescript/package.json b/packages/metro-plugin-typescript/package.json index 1d241c9ee..25dd78532 100644 --- a/packages/metro-plugin-typescript/package.json +++ b/packages/metro-plugin-typescript/package.json @@ -19,9 +19,6 @@ "url": "https://github.com/microsoft/rnx-kit", "directory": "packages/metro-plugin-typescript" }, - "engines": { - "node": ">=14.15" - }, "scripts": { "build": "rnx-kit-scripts build", "format": "rnx-kit-scripts format", @@ -49,6 +46,9 @@ "metro": "^0.80.3", "prettier": "^3.0.0" }, + "engines": { + "node": ">=16.17" + }, "jest": { "preset": "@rnx-kit/jest-preset/private" } diff --git a/packages/metro-resolver-symlinks/package.json b/packages/metro-resolver-symlinks/package.json index 020dc3624..7624e3704 100644 --- a/packages/metro-resolver-symlinks/package.json +++ b/packages/metro-resolver-symlinks/package.json @@ -43,5 +43,8 @@ "metro-resolver": "^0.80.3", "prettier": "^3.0.0", "typescript": "^5.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/metro-serializer-esbuild/package.json b/packages/metro-serializer-esbuild/package.json index 4fdc21056..397ec5b85 100644 --- a/packages/metro-serializer-esbuild/package.json +++ b/packages/metro-serializer-esbuild/package.json @@ -59,6 +59,9 @@ "react-native": "^0.75.0", "typescript": "^5.0.0" }, + "engines": { + "node": ">=16.17" + }, "depcheck": { "ignoreMatches": [ "@babel/preset-env" diff --git a/packages/metro-serializer-esbuild/test/index.test.ts b/packages/metro-serializer-esbuild/test/index.test.ts index 00cc11a65..62bfeb558 100644 --- a/packages/metro-serializer-esbuild/test/index.test.ts +++ b/packages/metro-serializer-esbuild/test/index.test.ts @@ -174,7 +174,7 @@ describe("metro-serializer-esbuild", () => { " // virtual:metro:__rnx_prelude__", ' var global = new Function("return this;")();', "", - ` // ${path.relative(root, _head).replace(/[\\]/g, "/")}`, + ` // ${path.relative(root, _head).replaceAll("\\", "/")}`, " function head(array) {", " return array && array.length ? array[0] : void 0;", " }", @@ -192,7 +192,7 @@ describe("metro-serializer-esbuild", () => { const m = require.resolve(spec, { paths: [parent] }); return path .relative(root, m) - .replace(/[\\]/g, "/") + .replaceAll("\\", "/") .replace("/lib-commonjs/", "/lib/"); }; diff --git a/packages/metro-serializer/package.json b/packages/metro-serializer/package.json index 0b8c418fe..045c691f8 100644 --- a/packages/metro-serializer/package.json +++ b/packages/metro-serializer/package.json @@ -42,6 +42,9 @@ "prettier": "^3.0.0", "typescript": "^5.0.0" }, + "engines": { + "node": ">=16.17" + }, "jest": { "preset": "@rnx-kit/jest-preset/private" } diff --git a/packages/metro-service/package.json b/packages/metro-service/package.json index 38b493bc6..a64401723 100644 --- a/packages/metro-service/package.json +++ b/packages/metro-service/package.json @@ -26,9 +26,6 @@ "lint": "rnx-kit-scripts lint", "test": "rnx-kit-scripts test" }, - "engines": { - "node": ">=12.13" - }, "dependencies": { "@rnx-kit/console": "^1.1.0", "@rnx-kit/tools-node": "^2.1.0", @@ -68,5 +65,8 @@ "metro-runtime": "^0.80.3", "prettier": "^3.0.0", "typescript": "^5.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/metro-service/src/asset/default.ts b/packages/metro-service/src/asset/default.ts index d2a317f58..b262314df 100644 --- a/packages/metro-service/src/asset/default.ts +++ b/packages/metro-service/src/asset/default.ts @@ -8,7 +8,7 @@ export function getAssetDestPath(asset: PackagerAsset, scale: number): string { // Assets can have relative paths outside of the project root. // Replace `../` with `_` to make sure they don't end up outside of // the expected assets directory. - asset.httpServerLocation.substr(1).replace(/\.\.\//g, "_"), + asset.httpServerLocation.substr(1).replaceAll("../", "_"), fileName ); } diff --git a/packages/metro-service/src/assets-registry/path-support.js b/packages/metro-service/src/assets-registry/path-support.js index 94c9775c0..c730e70ef 100644 --- a/packages/metro-service/src/assets-registry/path-support.js +++ b/packages/metro-service/src/assets-registry/path-support.js @@ -78,7 +78,7 @@ function getAndroidResourceFolderName( function getAndroidResourceIdentifier(asset) { return (getBasePath(asset) + '/' + asset.name) .toLowerCase() - .replace(/\//g, '_') // Encode folder structure in file name + .replaceAll("/", '_') // Encode folder structure in file name .replace(/([^a-z0-9_])/g, '') // Remove illegal chars .replace(/^assets_/, ''); // Remove "assets_" prefix } diff --git a/packages/react-native-auth/package.json b/packages/react-native-auth/package.json index 662f11592..5c4afb23b 100644 --- a/packages/react-native-auth/package.json +++ b/packages/react-native-auth/package.json @@ -51,6 +51,9 @@ "react-native": "^0.75.0", "typescript": "^5.0.0" }, + "engines": { + "node": ">=16.17" + }, "rnx-kit": { "alignDeps": { "presets": [ diff --git a/packages/react-native-host/package.json b/packages/react-native-host/package.json index f818e0e15..b6015d7f7 100644 --- a/packages/react-native-host/package.json +++ b/packages/react-native-host/package.json @@ -33,5 +33,8 @@ "@rnx-kit/scripts": "*", "@rnx-kit/tsconfig": "*", "prettier": "^3.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/react-native-lazy-index/package.json b/packages/react-native-lazy-index/package.json index aca4f5713..25a19fd32 100644 --- a/packages/react-native-lazy-index/package.json +++ b/packages/react-native-lazy-index/package.json @@ -54,6 +54,9 @@ "prettier": "^3.0.0", "typescript": "^5.0.0" }, + "engines": { + "node": ">=16.17" + }, "depcheck": { "ignoreMatches": [ "babel-plugin-codegen" diff --git a/packages/test-app/package.json b/packages/test-app/package.json index a8d709160..db9770701 100644 --- a/packages/test-app/package.json +++ b/packages/test-app/package.json @@ -25,7 +25,7 @@ "macos": "rnx run-macos --scheme ReactTestApp --no-packager", "ram-bundle": "rnx ram-bundle", "start": "rnx start", - "test": "rnx test --platform ios", + "test": "rnx test --platform ios --cache false", "windows": "rnx run-windows --no-packager --sln windows/SampleCrossApp.sln" }, "dependencies": { diff --git a/packages/test-app/tsconfig.json b/packages/test-app/tsconfig.json index be1621b3c..65fc206b3 100644 --- a/packages/test-app/tsconfig.json +++ b/packages/test-app/tsconfig.json @@ -6,7 +6,8 @@ "paths": { "@/*": ["./src/internal/*"], "internal": ["./src/internal"] - } + }, + "lib": ["ES2021", "DOM"] }, "include": ["src"] } diff --git a/packages/third-party-notices/package.json b/packages/third-party-notices/package.json index be951158e..499b771b4 100644 --- a/packages/third-party-notices/package.json +++ b/packages/third-party-notices/package.json @@ -50,6 +50,9 @@ "prettier": "^3.0.0", "typescript": "^5.0.0" }, + "engines": { + "node": ">=16.17" + }, "jest": { "preset": "@rnx-kit/jest-preset/private" } diff --git a/packages/third-party-notices/src/write-third-party-notices.ts b/packages/third-party-notices/src/write-third-party-notices.ts index c3f789c06..4bd7dd49c 100644 --- a/packages/third-party-notices/src/write-third-party-notices.ts +++ b/packages/third-party-notices/src/write-third-party-notices.ts @@ -104,7 +104,7 @@ export async function getCurrentPackageId( // helper functions export function normalizePath(p: string, currentPackageId?: string): string { - let result = p.replace(/webpack:\/\/\//g, ""); + let result = p.replaceAll("webpack:///", ""); if (currentPackageId) { result = result.replace( new RegExp(`webpack://${currentPackageId}/`, "g"), diff --git a/packages/tools-android/package.json b/packages/tools-android/package.json index 6eea130c1..bfb042f94 100644 --- a/packages/tools-android/package.json +++ b/packages/tools-android/package.json @@ -44,5 +44,8 @@ "eslint": "^8.56.0", "prettier": "^3.0.0", "typescript": "^5.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/tools-apple/package.json b/packages/tools-apple/package.json index 1f63aa211..974dd1b31 100644 --- a/packages/tools-apple/package.json +++ b/packages/tools-apple/package.json @@ -60,5 +60,8 @@ "eslint": "^8.56.0", "prettier": "^3.0.0", "typescript": "^5.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/tools-filesystem/package.json b/packages/tools-filesystem/package.json index a748ea33b..ff636e9dd 100644 --- a/packages/tools-filesystem/package.json +++ b/packages/tools-filesystem/package.json @@ -47,5 +47,8 @@ "eslint": "^8.56.0", "prettier": "^3.0.0", "typescript": "^5.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/tools-language/package.json b/packages/tools-language/package.json index af04daf15..56647ce0a 100644 --- a/packages/tools-language/package.json +++ b/packages/tools-language/package.json @@ -50,5 +50,8 @@ "eslint": "^8.56.0", "prettier": "^3.0.0", "typescript": "^5.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/tools-node/package.json b/packages/tools-node/package.json index 6395c1c00..f79c1ed36 100644 --- a/packages/tools-node/package.json +++ b/packages/tools-node/package.json @@ -64,5 +64,8 @@ "eslint": "^8.56.0", "prettier": "^3.0.0", "typescript": "^5.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/tools-node/src/path.ts b/packages/tools-node/src/path.ts index cc61ea041..018915676 100644 --- a/packages/tools-node/src/path.ts +++ b/packages/tools-node/src/path.ts @@ -72,5 +72,5 @@ export function findUp( * @returns Normalized path */ export function normalizePath(p: string): string { - return p.replace(/\\/g, "/"); + return p.replaceAll("\\", "/"); } diff --git a/packages/tools-react-native/package.json b/packages/tools-react-native/package.json index abec16cb2..886638728 100644 --- a/packages/tools-react-native/package.json +++ b/packages/tools-react-native/package.json @@ -82,5 +82,8 @@ "metro-source-map": "^0.80.0", "prettier": "^3.0.0", "typescript": "^5.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/tools-shell/package.json b/packages/tools-shell/package.json index 60e30c659..ec4756983 100644 --- a/packages/tools-shell/package.json +++ b/packages/tools-shell/package.json @@ -56,6 +56,9 @@ "prettier": "^3.0.0", "typescript": "^5.0.0" }, + "engines": { + "node": ">=16.17" + }, "jest": { "preset": "@rnx-kit/jest-preset/private" } diff --git a/packages/tools-windows/package.json b/packages/tools-windows/package.json index 468d15282..d93b7e236 100644 --- a/packages/tools-windows/package.json +++ b/packages/tools-windows/package.json @@ -45,5 +45,8 @@ "eslint": "^8.56.0", "prettier": "^3.0.0", "typescript": "^5.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/tools-windows/src/index.ts b/packages/tools-windows/src/index.ts index 070decd07..2a613e96b 100644 --- a/packages/tools-windows/src/index.ts +++ b/packages/tools-windows/src/index.ts @@ -90,7 +90,7 @@ function normalizePath(p: string): string { const { root } = path.parse(p); const m = root.toLowerCase().match(/([a-z]+)/); - return m ? `/${m[1]}/${p.substring(root.length)}`.replace(/\\/g, "/") : p; + return m ? `/${m[1]}/${p.substring(root.length)}`.replaceAll("\\", "/") : p; } /** diff --git a/packages/tools-workspaces/package.json b/packages/tools-workspaces/package.json index 17fee57bb..989624c45 100644 --- a/packages/tools-workspaces/package.json +++ b/packages/tools-workspaces/package.json @@ -51,6 +51,6 @@ "typescript": "^5.0.0" }, "engines": { - "node": ">=14.15" + "node": ">=16.17" } } diff --git a/packages/tsconfig/package.json b/packages/tsconfig/package.json index bbd222293..e57172f75 100644 --- a/packages/tsconfig/package.json +++ b/packages/tsconfig/package.json @@ -40,5 +40,8 @@ }, "devDependencies": { "prettier": "^3.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/tsconfig/tsconfig.esm.json b/packages/tsconfig/tsconfig.esm.json index c14e95651..af7593310 100644 --- a/packages/tsconfig/tsconfig.esm.json +++ b/packages/tsconfig/tsconfig.esm.json @@ -1,7 +1,6 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "target": "ES2020", "module": "Node16", "moduleResolution": "Node16", "verbatimModuleSyntax": true diff --git a/packages/tsconfig/tsconfig.json b/packages/tsconfig/tsconfig.json index bad2f44f0..23f5bc0b9 100644 --- a/packages/tsconfig/tsconfig.json +++ b/packages/tsconfig/tsconfig.json @@ -20,7 +20,8 @@ "forceConsistentCasingInFileNames": true, "isolatedModules": true, "jsx": "react", - "target": "ES2019", + "lib": ["ES2021"], + "target": "ES2021", "pretty": true, "skipLibCheck": true, "skipDefaultLibCheck": true diff --git a/packages/typescript-service/package.json b/packages/typescript-service/package.json index b5afbe685..e308f41e0 100644 --- a/packages/typescript-service/package.json +++ b/packages/typescript-service/package.json @@ -39,5 +39,8 @@ "eslint": "^8.56.0", "prettier": "^3.0.0", "typescript": "^5.0.0" + }, + "engines": { + "node": ">=16.17" } } diff --git a/packages/typescript-service/src/config.ts b/packages/typescript-service/src/config.ts index 91c68c24c..8ea6707bd 100644 --- a/packages/typescript-service/src/config.ts +++ b/packages/typescript-service/src/config.ts @@ -38,7 +38,7 @@ export function readConfigFile( // to posix path separators. This all happens internally to TS and seems // like a regression. The workaround is to convert to posix separators, // even on Windows, since they are supported across all platforms. - const configFileNamePosix = configFileName.replace(/\\/g, "/"); + const configFileNamePosix = configFileName.replaceAll("\\", "/"); return ts.getParsedCommandLineOfConfigFile( configFileNamePosix, diff --git a/scripts/lint-metadata.js b/scripts/lint-metadata.js index c1988045c..8521369c3 100644 --- a/scripts/lint-metadata.js +++ b/scripts/lint-metadata.js @@ -1,78 +1,98 @@ import { spawnSync } from "node:child_process"; -import * as fs from "node:fs"; +import * as fs from "node:fs/promises"; import * as path from "node:path"; -const defaultAuthor = { +const DEFAULT_AUTHOR = { name: "Microsoft Open Source", email: "microsoftopensource@users.noreply.github.com", }; -const ignoredLocations = [".", "packages/test-app", "scripts"]; + +const MIN_NODE_VERSION = ">=16.17"; +const MIN_NODE_VERSION_NUM = 16017; + +const IGNORED_LOCATIONS = [".", "packages/test-app", "scripts"]; + const options = { encoding: "utf-8" }; -fs.readFile("package.json", options, (err, data) => { - if (err) { - throw err; +function satisfiesMinNodeVersion(version) { + if (!version) { + return false; + } + + const m = version.match(/(\d+)\.(\d+)/); + if (!m) { + return false; } + const [, major, minor] = m; + return Number(major) * 1000 + Number(minor) >= MIN_NODE_VERSION_NUM; +} + +fs.readFile("package.json", options).then((data) => { const { repository: origin } = JSON.parse(data); const yarn = spawnSync("yarn", ["workspaces", "list", "--json"], options); const workspaces = yarn.stdout.trim().split("\n"); - for (const { location } of workspaces.map((json) => JSON.parse(json))) { - if (ignoredLocations.includes(location)) { - continue; + const jobs = workspaces.map(async (json) => { + const { location } = JSON.parse(json); + if (IGNORED_LOCATIONS.includes(location)) { + return; } - const pkgJsonPath = path.join(location, "package.json"); let needsUpdate = false; - fs.readFile(pkgJsonPath, options, (err, data) => { - if (err) { - throw err; - } - const manifest = JSON.parse(data); - const { author, homepage, repository } = manifest; + const pkgJsonPath = path.join(location, "package.json"); + const data = await fs.readFile(pkgJsonPath, options); + const manifest = JSON.parse(data); + const { author, homepage, repository, engines } = manifest; - const readmeUrl = `${origin.url}/tree/main/${location}#readme`; - if (homepage !== readmeUrl) { - needsUpdate = true; - manifest.homepage = readmeUrl; - } + const readmeUrl = `${origin.url}/tree/main/${location}#readme`; + if (homepage !== readmeUrl) { + needsUpdate = true; + manifest.homepage = readmeUrl; + } - if ( - author?.name !== defaultAuthor.name || - author?.email !== defaultAuthor.email - ) { - needsUpdate = true; - manifest.author = defaultAuthor; - } + if ( + author?.name !== DEFAULT_AUTHOR.name || + author?.email !== DEFAULT_AUTHOR.email + ) { + needsUpdate = true; + manifest.author = DEFAULT_AUTHOR; + } - if ( - repository?.type !== origin.type || - repository?.url !== origin.url || - repository?.directory !== location - ) { - needsUpdate = true; - manifest.repository = { - ...origin, - directory: location, - }; - } + if ( + repository?.type !== origin.type || + repository?.url !== origin.url || + repository?.directory !== location + ) { + needsUpdate = true; + manifest.repository = { + ...origin, + directory: location, + }; + } - if (needsUpdate) { - fs.writeFile( - pkgJsonPath, - JSON.stringify(manifest, undefined, 2) + "\n", - (err) => { - if (err) { - throw err; - } - - console.log("Updated", pkgJsonPath); - } - ); + if (!satisfiesMinNodeVersion(engines?.node)) { + needsUpdate = true; + manifest.engines = { + ...engines, + node: MIN_NODE_VERSION, + }; + } + + if (needsUpdate) { + let fh; + try { + fh = await fs.open(pkgJsonPath, "w"); + await fh.write(JSON.stringify(manifest, undefined, 2)); + await fh.write("\n"); + console.log("Updated", pkgJsonPath); + } finally { + await fh?.close(); } - }); - } + } + }); + + return Promise.allSettled(jobs); }); diff --git a/scripts/new-package.js b/scripts/new-package.js index 548d1e3a9..bc9620053 100644 --- a/scripts/new-package.js +++ b/scripts/new-package.js @@ -87,7 +87,7 @@ async function main(projectName, { experimental }) { const readmePath = path.join(newProjectDir, "README.md"); fs.readFile(readmePath, { encoding: "utf-8" }).then((readme) => { const updatedReadme = readme - .replace(/template/g, cleanProjectName) + .replaceAll("template", cleanProjectName) .replace(WARNING_BANNER_TOKEN, experimental ? EXPERIMENTAL_BANNER : "") .replace(new RegExp(`${USAGE_TOKEN_START}([^]+)${USAGE_TOKEN_END}`), ""); diff --git a/scripts/src/commands/bundle.js b/scripts/src/commands/bundle.js index 53a368e19..bbaad0d0e 100644 --- a/scripts/src/commands/bundle.js +++ b/scripts/src/commands/bundle.js @@ -36,17 +36,18 @@ export async function bundle(options) { const esbuild = await import("esbuild"); await esbuild.build({ bundle: true, - conditions: ["typescript"], - entryPoints: ["src/index.ts"], + outfile: main, external: [ ...(dependencies ? Object.keys(dependencies) : []), ...(peerDependencies ? Object.keys(peerDependencies) : []), "./package.json", ], - minify: Boolean(minify), - outfile: main, - platform: targetPlatform, + conditions: ["typescript"], banner: targetPlatform === "node" ? { js: "#!/usr/bin/env node" } : undefined, + entryPoints: ["src/index.ts"], + target: targetPlatform === "node" ? "node16.17.0" : "es2021", + platform: targetPlatform, + minify: Boolean(minify), }); } diff --git a/scripts/src/commands/updateApiReadme.js b/scripts/src/commands/updateApiReadme.js index f7cbf5611..a830c9004 100644 --- a/scripts/src/commands/updateApiReadme.js +++ b/scripts/src/commands/updateApiReadme.js @@ -104,7 +104,7 @@ function renderSummary(parts) { const comment = result.join(""); const paragraph = comment.indexOf("\n\n"); const summary = paragraph > 0 ? comment.substring(0, paragraph) : comment; - return summary.replace(/\n/g, " "); + return summary.replaceAll("\n", " "); } /**