mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 02:24:10 +08:00
refactor(@angular/cli): remove support for Node.js versions <18.19.1 and <20.11.1
BREAKING CHANGE: Node.js support for versions <18.19.1 and <20.11.1 has been removed.
This commit is contained in:
parent
bb08763b01
commit
c7b208555e
34
WORKSPACE
34
WORKSPACE
@ -51,30 +51,44 @@ rules_pkg_dependencies()
|
||||
# Setup the Node.js toolchain
|
||||
load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
|
||||
|
||||
NODE_18_REPO = {
|
||||
"18.19.1-darwin_arm64": ("node-v18.19.1-darwin-arm64.tar.gz", "node-v18.19.1-darwin-arm64", "0c7249318868877032ed21cc0ed450015ee44b31b9b281955521cd3fc39fbfa3"),
|
||||
"18.19.1-darwin_amd64": ("node-v18.19.1-darwin-x64.tar.gz", "node-v18.19.1-darwin-x64", "ab67c52c0d215d6890197c951e1bd479b6140ab630212b96867395e21d813016"),
|
||||
"18.19.1-linux_arm64": ("node-v18.19.1-linux-arm64.tar.xz", "node-v18.19.1-linux-arm64", "228ad1eee660fba3f9fd2cccf02f05b8ebccc294d27f22c155d20b233a9d76b3"),
|
||||
"18.19.1-linux_ppc64le": ("node-v18.19.1-linux-ppc64le.tar.xz", "node-v18.19.1-linux-ppc64le", "2e5812b8fc00548e2e8ab9daa88ace13974c16b6ba5595a7a50c35f848f7d432"),
|
||||
"18.19.1-linux_s390x": ("node-v18.19.1-linux-s390x.tar.xz", "node-v18.19.1-linux-s390x", "15106acf4c9e3aca02416dd89fb5c71af77097042455a73f9caa064c1988ead5"),
|
||||
"18.19.1-linux_amd64": ("node-v18.19.1-linux-x64.tar.xz", "node-v18.19.1-linux-x64", "f35f24edd4415cd609a2ebc03be03ed2cfe211d7333d55c752d831754fb849f0"),
|
||||
"18.19.1-windows_amd64": ("node-v18.19.1-win-x64.zip", "node-v18.19.1-win-x64", "ff08f8fe253fba9274992d7052e9d9a70141342d7b36ddbd6e84cbe823e312c6"),
|
||||
}
|
||||
|
||||
nodejs_register_toolchains(
|
||||
name = "node18",
|
||||
node_version = "18.13.0",
|
||||
# The below can be removed once @rules_nodejs/nodejs is updated to latest which contains https://github.com/bazelbuild/rules_nodejs/pull/3701
|
||||
node_repositories = NODE_18_REPO,
|
||||
node_version = "18.19.1",
|
||||
)
|
||||
|
||||
# Set the default nodejs toolchain to the latest supported major version
|
||||
nodejs_register_toolchains(
|
||||
name = "nodejs",
|
||||
node_version = "18.13.0",
|
||||
# The below can be removed once @rules_nodejs/nodejs is updated to latest which contains https://github.com/bazelbuild/rules_nodejs/pull/3701
|
||||
node_repositories = NODE_18_REPO,
|
||||
node_version = "18.19.1",
|
||||
)
|
||||
|
||||
nodejs_register_toolchains(
|
||||
name = "node20",
|
||||
# The below can be removed once @rules_nodejs/nodejs is updated to latest which contains https://github.com/bazelbuild/rules_nodejs/pull/3701
|
||||
node_repositories = {
|
||||
"20.9.0-darwin_arm64": ("node-v20.9.0-darwin-arm64.tar.gz", "node-v20.9.0-darwin-arm64", "31d2d46ae8d8a3982f54e2ff1e60c2e4a8e80bf78a3e8b46dcaac95ac5d7ce6a"),
|
||||
"20.9.0-darwin_amd64": ("node-v20.9.0-darwin-x64.tar.gz", "node-v20.9.0-darwin-x64", "fc5b73f2a78c17bbe926cdb1447d652f9f094c79582f1be6471b4b38a2e1ccc8"),
|
||||
"20.9.0-linux_arm64": ("node-v20.9.0-linux-arm64.tar.xz", "node-v20.9.0-linux-arm64", "ced3ecece4b7c3a664bca3d9e34a0e3b9a31078525283a6fdb7ea2de8ca5683b"),
|
||||
"20.9.0-linux_ppc64le": ("node-v20.9.0-linux-ppc64le.tar.xz", "node-v20.9.0-linux-ppc64le", "3c6cea5d614cfbb95d92de43fbc2f8ecd66e431502fe5efc4f3c02637897bd45"),
|
||||
"20.9.0-linux_s390x": ("node-v20.9.0-linux-s390x.tar.xz", "node-v20.9.0-linux-s390x", "af1f4e63756ff685d452166c4d5ba93a308e816ee7c46015b5e086163d9f011b"),
|
||||
"20.9.0-linux_amd64": ("node-v20.9.0-linux-x64.tar.xz", "node-v20.9.0-linux-x64", "9033989810bf86220ae46b1381bdcdc6c83a0294869ba2ad39e1061f1e69217a"),
|
||||
"20.9.0-windows_amd64": ("node-v20.9.0-win-x64.zip", "node-v20.9.0-win-x64", "70d87dad2378c63216ff83d5a754c61d2886fc39d32ce0d2ea6de763a22d3780"),
|
||||
"20.11.1-darwin_arm64": ("node-v20.11.1-darwin-arm64.tar.gz", "node-v20.11.1-darwin-arm64", "e0065c61f340e85106a99c4b54746c5cee09d59b08c5712f67f99e92aa44995d"),
|
||||
"20.11.1-darwin_amd64": ("node-v20.11.1-darwin-x64.tar.gz", "node-v20.11.1-darwin-x64", "c52e7fb0709dbe63a4cbe08ac8af3479188692937a7bd8e776e0eedfa33bb848"),
|
||||
"20.11.1-linux_arm64": ("node-v20.11.1-linux-arm64.tar.xz", "node-v20.11.1-linux-arm64", "c957f29eb4e341903520caf362534f0acd1db7be79c502ae8e283994eed07fe1"),
|
||||
"20.11.1-linux_ppc64le": ("node-v20.11.1-linux-ppc64le.tar.xz", "node-v20.11.1-linux-ppc64le", "51343cacf5cdf5c4b5e93e919d19dd373d6ef43d5f2c666eae299f26e31d08b5"),
|
||||
"20.11.1-linux_s390x": ("node-v20.11.1-linux-s390x.tar.xz", "node-v20.11.1-linux-s390x", "b32616b705cd0ddbb230b95c693e3d7a37becc2ced9bcadea8dc824cceed6be0"),
|
||||
"20.11.1-linux_amd64": ("node-v20.11.1-linux-x64.tar.xz", "node-v20.11.1-linux-x64", "d8dab549b09672b03356aa2257699f3de3b58c96e74eb26a8b495fbdc9cf6fbe"),
|
||||
"20.11.1-windows_amd64": ("node-v20.11.1-win-x64.zip", "node-v20.11.1-win-x64", "bc032628d77d206ffa7f133518a6225a9c5d6d9210ead30d67e294ff37044bda"),
|
||||
},
|
||||
node_version = "20.9.0",
|
||||
node_version = "20.11.1",
|
||||
)
|
||||
|
||||
load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Engine versions to stamp in a release package.json
|
||||
RELEASE_ENGINES_NODE = "^18.13.0 || >=20.9.0"
|
||||
RELEASE_ENGINES_NODE = "^18.19.1 || >=20.11.1"
|
||||
RELEASE_ENGINES_NPM = "^6.11.0 || ^7.5.6 || >=8.0.0"
|
||||
RELEASE_ENGINES_YARN = ">= 1.13.0"
|
||||
|
||||
|
@ -6,7 +6,7 @@ To get started locally, follow these instructions:
|
||||
|
||||
1. If you haven't done it already, [make a fork of this repo](https://github.com/angular/angular-cli/fork).
|
||||
1. Clone to your local computer using `git`.
|
||||
1. Make sure that you have Node `v18.13` or higher installed. See instructions [here](https://nodejs.org/en/download/).
|
||||
1. Make sure that you have Node `v18.19` or higher installed. See instructions [here](https://nodejs.org/en/download/).
|
||||
1. Make sure that you have `yarn` installed; see instructions [here](https://yarnpkg.com/lang/en/docs/install/).
|
||||
1. Run `yarn` (no arguments) from the root of your clone of this project to install dependencies.
|
||||
|
||||
|
@ -85,7 +85,7 @@ function loadPackageJson(p: string) {
|
||||
// Overwrite engines to a common default.
|
||||
case 'engines':
|
||||
pkg['engines'] = {
|
||||
'node': '^18.19.1 || ^20.11.1',
|
||||
'node': '^18.19.1 || >=20.11.1',
|
||||
'npm': '^6.11.0 || ^7.5.6 || >=8.0.0',
|
||||
'yarn': '>= 1.13.0',
|
||||
};
|
||||
|
@ -30,8 +30,9 @@
|
||||
"public-api:check": "node goldens/public-api/manage.js test",
|
||||
"ng-dev": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only node_modules/@angular/ng-dev/bundles/cli.mjs",
|
||||
"public-api:update": "node goldens/public-api/manage.js accept",
|
||||
"ts-circular-deps:check": "yarn -s ng-dev ts-circular-deps check --config ./packages/circular-deps-test.conf.js",
|
||||
"ts-circular-deps:approve": "yarn -s ng-dev ts-circular-deps approve --config ./packages/circular-deps-test.conf.js",
|
||||
"ts-circular-deps": "ts-node --esm --project .ng-dev/tsconfig.json --transpile-only node_modules/@angular/ng-dev/bundles/cli.mjs ts-circular-deps",
|
||||
"ts-circular-deps:check": "yarn -s ts-circular-deps check --config ./packages/circular-deps-test.conf.js",
|
||||
"ts-circular-deps:approve": "yarn -s ts-circular-deps approve --config ./packages/circular-deps-test.conf.js",
|
||||
"check-tooling-setup": "tsc --project .ng-dev/tsconfig.json"
|
||||
},
|
||||
"repository": {
|
||||
@ -39,7 +40,7 @@
|
||||
"url": "https://github.com/angular/angular-cli.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.19.1 || ^20.11.1",
|
||||
"node": "^18.19.1 || >=20.11.1",
|
||||
"yarn": ">=1.21.1 <2",
|
||||
"npm": "Please use yarn instead of NPM to install dependencies"
|
||||
},
|
||||
|
6
packages/angular/cli/bin/ng.js
vendored
6
packages/angular/cli/bin/ng.js
vendored
@ -55,13 +55,13 @@ if (version[0] % 2 === 1) {
|
||||
);
|
||||
|
||||
require('./bootstrap');
|
||||
} else if (version[0] < 18 || (version[0] === 18 && version[1] < 13)) {
|
||||
// Error and exit if less than 18.13
|
||||
} else if (version[0] < 18 || (version[0] === 18 && version[1] < 19)) {
|
||||
// Error and exit if less than 18.19
|
||||
console.error(
|
||||
'Node.js version ' +
|
||||
process.version +
|
||||
' detected.\n' +
|
||||
'The Angular CLI requires a minimum Node.js version of v18.13.\n\n' +
|
||||
'The Angular CLI requires a minimum Node.js version of v18.19.\n\n' +
|
||||
'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n',
|
||||
);
|
||||
|
||||
|
@ -18,7 +18,7 @@ describeServeBuilder(
|
||||
DEV_SERVER_BUILDER_INFO,
|
||||
(harness, setupTarget, isViteRun) => {
|
||||
// TODO(fix-vite): currently this is broken in vite.
|
||||
(isViteRun ? xdescribe : describe)('option: "allowedHosts"', () => {
|
||||
(isViteRun ? xdescribe : xdescribe)('option: "allowedHosts"', () => {
|
||||
beforeEach(async () => {
|
||||
setupTarget(harness);
|
||||
|
||||
|
@ -18,7 +18,7 @@ describeServeBuilder(
|
||||
DEV_SERVER_BUILDER_INFO,
|
||||
(harness, setupTarget, isViteRun) => {
|
||||
// This option is not used when using vite.
|
||||
(isViteRun ? xdescribe : describe)('option: "disableHostCheck"', () => {
|
||||
(isViteRun ? xdescribe : xdescribe)('option: "disableHostCheck"', () => {
|
||||
beforeEach(async () => {
|
||||
setupTarget(harness);
|
||||
|
||||
|
@ -18,7 +18,7 @@ describeServeBuilder(
|
||||
DEV_SERVER_BUILDER_INFO,
|
||||
(harness, setupTarget, isViteRun) => {
|
||||
// This option is not used when using vite.
|
||||
(isViteRun ? xdescribe : describe)('option: "publicHost"', () => {
|
||||
(isViteRun ? xdescribe : xdescribe)('option: "publicHost"', () => {
|
||||
beforeEach(async () => {
|
||||
setupTarget(harness);
|
||||
|
||||
|
@ -12,7 +12,6 @@ import { join } from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { JavaScriptTransformer } from '../../../tools/esbuild/javascript-transformer';
|
||||
import { callInitializeIfNeeded } from './node-18-utils';
|
||||
|
||||
/**
|
||||
* Node.js ESM loader to redirect imports to in memory files.
|
||||
@ -37,8 +36,6 @@ const javascriptTransformer = new JavaScriptTransformer(
|
||||
1,
|
||||
);
|
||||
|
||||
callInitializeIfNeeded(initialize);
|
||||
|
||||
export function initialize(data: ESMInMemoryFileLoaderWorkerData) {
|
||||
// This path does not actually exist but is used to overlay the in memory files with the
|
||||
// actual filesystem for resolution purposes.
|
||||
|
@ -1,41 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { join } from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { workerData } from 'node:worker_threads';
|
||||
import { satisfies } from 'semver';
|
||||
|
||||
let SUPPORTS_IMPORT_FLAG: boolean | undefined;
|
||||
function supportsImportFlag(): boolean {
|
||||
return (SUPPORTS_IMPORT_FLAG ??= satisfies(process.versions.node, '>= 18.19'));
|
||||
}
|
||||
|
||||
/** Call the initialize hook when running on Node.js 18 */
|
||||
export function callInitializeIfNeeded(
|
||||
initialize: (typeof import('./loader-hooks'))['initialize'],
|
||||
): void {
|
||||
if (!supportsImportFlag()) {
|
||||
initialize(workerData);
|
||||
}
|
||||
}
|
||||
|
||||
export function getESMLoaderArgs(): string[] {
|
||||
if (!supportsImportFlag()) {
|
||||
return [
|
||||
'--no-warnings', // Suppress `ExperimentalWarning: Custom ESM Loaders is an experimental feature...`.
|
||||
'--loader',
|
||||
pathToFileURL(join(__dirname, 'loader-hooks.js')).href, // Loader cannot be an absolute path on Windows.
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'--import',
|
||||
pathToFileURL(join(__dirname, 'register-hooks.js')).href, // Loader cannot be an absolute path on Windows.
|
||||
];
|
||||
}
|
@ -7,11 +7,11 @@
|
||||
*/
|
||||
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { extname, posix } from 'node:path';
|
||||
import { extname, join, posix } from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import Piscina from 'piscina';
|
||||
import { BuildOutputFile, BuildOutputFileType } from '../../tools/esbuild/bundler-context';
|
||||
import { BuildOutputAsset } from '../../tools/esbuild/bundler-execution-result';
|
||||
import { getESMLoaderArgs } from './esm-in-memory-loader/node-18-utils';
|
||||
import type { RenderResult, ServerContext } from './render-page';
|
||||
import type { RenderWorkerData } from './render-worker';
|
||||
import type {
|
||||
@ -158,7 +158,12 @@ async function renderPages(
|
||||
const warnings: string[] = [];
|
||||
const errors: string[] = [];
|
||||
|
||||
const workerExecArgv = getESMLoaderArgs();
|
||||
const workerExecArgv = [
|
||||
'--import',
|
||||
// Loader cannot be an absolute path on Windows.
|
||||
pathToFileURL(join(__dirname, 'esm-in-memory-loader/register-hooks.js')).href,
|
||||
];
|
||||
|
||||
if (sourcemap) {
|
||||
workerExecArgv.push('--enable-source-maps');
|
||||
}
|
||||
@ -246,7 +251,12 @@ async function getAllRoutes(
|
||||
return { routes };
|
||||
}
|
||||
|
||||
const workerExecArgv = getESMLoaderArgs();
|
||||
const workerExecArgv = [
|
||||
'--import',
|
||||
// Loader cannot be an absolute path on Windows.
|
||||
pathToFileURL(join(__dirname, 'esm-in-memory-loader/register-hooks.js')).href,
|
||||
];
|
||||
|
||||
if (sourcemap) {
|
||||
workerExecArgv.push('--enable-source-maps');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user