@angular-devkit/build-angular 17.3.2 → 18.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +33 -33
- package/src/builders/app-shell/index.js +1 -1
- package/src/builders/application/build-action.d.ts +2 -3
- package/src/builders/application/options.d.ts +3 -1
- package/src/builders/application/schema.d.ts +1 -1
- package/src/builders/application/schema.json +2 -1
- package/src/builders/browser/schema.d.ts +1 -1
- package/src/builders/browser/schema.json +2 -1
- package/src/builders/browser-esbuild/schema.d.ts +1 -1
- package/src/builders/browser-esbuild/schema.json +2 -1
- package/src/builders/dev-server/builder.d.ts +0 -2
- package/src/builders/dev-server/vite-server.js +14 -7
- package/src/builders/dev-server/webpack-server.js +1 -1
- package/src/builders/karma/schema.d.ts +1 -1
- package/src/builders/karma/schema.json +2 -1
- package/src/builders/prerender/index.d.ts +2 -3
- package/src/builders/server/schema.d.ts +1 -1
- package/src/builders/server/schema.json +2 -1
- package/src/builders/ssr-dev-server/utils.d.ts +1 -2
- package/src/builders/web-test-runner/schema.d.ts +1 -1
- package/src/builders/web-test-runner/schema.json +2 -1
- package/src/tools/babel/plugins/adjust-static-class-members.js +3 -6
- package/src/tools/babel/plugins/index.d.ts +11 -0
- package/src/tools/babel/plugins/index.js +21 -0
- package/src/tools/babel/presets/application.js +4 -3
- package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +0 -2
- package/src/tools/esbuild/javascript-transformer-worker.js +82 -26
- package/src/tools/esbuild/utils.d.ts +2 -2
- package/src/tools/esbuild/utils.js +1 -1
- package/src/tools/vite/angular-memory-plugin.js +5 -7
- package/src/tools/webpack/configs/dev-server.js +20 -11
- package/src/tools/webpack/configs/styles.js +22 -53
- package/src/tools/webpack/plugins/builder-watch-plugin.js +2 -2
- package/src/tools/webpack/plugins/styles-webpack-plugin.js +1 -1
- package/src/tools/webpack/utils/helpers.js +1 -1
- package/src/utils/environment-options.d.ts +0 -1
- package/src/utils/environment-options.js +1 -11
- package/src/utils/i18n-options.d.ts +3 -2
- package/src/utils/i18n-options.js +39 -33
- package/src/utils/index-file/inline-fonts.d.ts +0 -4
- package/src/utils/index-file/inline-fonts.js +3 -5
- package/src/utils/normalize-asset-patterns.d.ts +4 -3
- package/src/utils/normalize-asset-patterns.js +7 -3
- package/src/utils/normalize-cache.d.ts +1 -2
- package/src/utils/normalize-cache.js +15 -9
- package/src/utils/normalize-file-replacements.d.ts +1 -2
- package/src/utils/normalize-file-replacements.js +1 -2
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +0 -2
- package/src/utils/server-rendering/prerender.js +11 -3
- package/src/utils/service-worker.d.ts +2 -2
- package/src/utils/supported-browsers.d.ts +3 -2
- package/src/utils/webpack-browser-config.d.ts +1 -2
- package/src/tools/sass/sass-service-legacy.d.ts +0 -51
- package/src/tools/sass/sass-service-legacy.js +0 -173
- package/src/tools/sass/worker-legacy.d.ts +0 -8
- package/src/tools/sass/worker-legacy.js +0 -43
- package/src/utils/server-rendering/esm-in-memory-loader/node-18-utils.d.ts +0 -10
- package/src/utils/server-rendering/esm-in-memory-loader/node-18-utils.js +0 -39
package/package.json
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.0-next.1",
|
|
4
4
|
"description": "Angular Webpack Build Facade",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"typings": "src/index.d.ts",
|
|
7
7
|
"builders": "builders.json",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@ampproject/remapping": "2.3.0",
|
|
10
|
-
"@angular-devkit/architect": "0.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.
|
|
12
|
-
"@angular-devkit/core": "
|
|
13
|
-
"@babel/core": "7.24.
|
|
14
|
-
"@babel/generator": "7.
|
|
10
|
+
"@angular-devkit/architect": "0.1800.0-next.1",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1800.0-next.1",
|
|
12
|
+
"@angular-devkit/core": "18.0.0-next.1",
|
|
13
|
+
"@babel/core": "7.24.3",
|
|
14
|
+
"@babel/generator": "7.24.1",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.22.5",
|
|
16
16
|
"@babel/helper-split-export-declaration": "7.22.6",
|
|
17
|
-
"@babel/plugin-transform-async-generator-functions": "7.
|
|
18
|
-
"@babel/plugin-transform-async-to-generator": "7.
|
|
19
|
-
"@babel/plugin-transform-runtime": "7.24.
|
|
20
|
-
"@babel/preset-env": "7.24.
|
|
21
|
-
"@babel/runtime": "7.24.
|
|
17
|
+
"@babel/plugin-transform-async-generator-functions": "7.24.3",
|
|
18
|
+
"@babel/plugin-transform-async-to-generator": "7.24.1",
|
|
19
|
+
"@babel/plugin-transform-runtime": "7.24.3",
|
|
20
|
+
"@babel/preset-env": "7.24.3",
|
|
21
|
+
"@babel/runtime": "7.24.1",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.7",
|
|
23
|
-
"@ngtools/webpack": "
|
|
23
|
+
"@ngtools/webpack": "18.0.0-next.1",
|
|
24
24
|
"@vitejs/plugin-basic-ssl": "1.1.0",
|
|
25
25
|
"ansi-colors": "4.1.3",
|
|
26
|
-
"autoprefixer": "10.4.
|
|
26
|
+
"autoprefixer": "10.4.19",
|
|
27
27
|
"babel-loader": "9.1.3",
|
|
28
28
|
"babel-plugin-istanbul": "6.1.1",
|
|
29
29
|
"browserslist": "^4.21.5",
|
|
30
30
|
"copy-webpack-plugin": "11.0.0",
|
|
31
31
|
"critters": "0.0.22",
|
|
32
32
|
"css-loader": "6.10.0",
|
|
33
|
-
"esbuild-wasm": "0.20.
|
|
33
|
+
"esbuild-wasm": "0.20.2",
|
|
34
34
|
"fast-glob": "3.3.2",
|
|
35
35
|
"https-proxy-agent": "7.0.4",
|
|
36
36
|
"http-proxy-middleware": "2.0.6",
|
|
37
|
-
"inquirer": "9.2.
|
|
37
|
+
"inquirer": "9.2.16",
|
|
38
38
|
"jsonc-parser": "3.2.1",
|
|
39
39
|
"karma-source-map-support": "1.4.0",
|
|
40
40
|
"less": "4.2.0",
|
|
41
|
-
"less-loader": "
|
|
41
|
+
"less-loader": "12.2.0",
|
|
42
42
|
"license-webpack-plugin": "4.0.2",
|
|
43
43
|
"loader-utils": "3.2.1",
|
|
44
44
|
"magic-string": "0.30.8",
|
|
@@ -49,44 +49,44 @@
|
|
|
49
49
|
"parse5-html-rewriting-stream": "7.0.0",
|
|
50
50
|
"picomatch": "4.0.1",
|
|
51
51
|
"piscina": "4.4.0",
|
|
52
|
-
"postcss": "8.4.
|
|
52
|
+
"postcss": "8.4.38",
|
|
53
53
|
"postcss-loader": "8.1.1",
|
|
54
54
|
"resolve-url-loader": "5.0.0",
|
|
55
55
|
"rxjs": "7.8.1",
|
|
56
|
-
"sass": "1.
|
|
56
|
+
"sass": "1.72.0",
|
|
57
57
|
"sass-loader": "14.1.1",
|
|
58
58
|
"semver": "7.6.0",
|
|
59
59
|
"source-map-loader": "5.0.0",
|
|
60
60
|
"source-map-support": "0.5.21",
|
|
61
|
-
"terser": "5.29.
|
|
61
|
+
"terser": "5.29.2",
|
|
62
62
|
"tree-kill": "1.2.2",
|
|
63
63
|
"tslib": "2.6.2",
|
|
64
|
-
"undici": "6.
|
|
65
|
-
"vite": "5.
|
|
66
|
-
"watchpack": "2.4.
|
|
67
|
-
"webpack": "5.
|
|
68
|
-
"webpack-dev-middleware": "
|
|
69
|
-
"webpack-dev-server": "
|
|
64
|
+
"undici": "6.10.1",
|
|
65
|
+
"vite": "5.2.6",
|
|
66
|
+
"watchpack": "2.4.1",
|
|
67
|
+
"webpack": "5.91.0",
|
|
68
|
+
"webpack-dev-middleware": "7.1.1",
|
|
69
|
+
"webpack-dev-server": "5.0.4",
|
|
70
70
|
"webpack-merge": "5.10.0",
|
|
71
71
|
"webpack-subresource-integrity": "5.1.0"
|
|
72
72
|
},
|
|
73
73
|
"optionalDependencies": {
|
|
74
|
-
"esbuild": "0.20.
|
|
74
|
+
"esbuild": "0.20.2"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@angular/compiler-cli": "^
|
|
78
|
-
"@angular/localize": "^
|
|
79
|
-
"@angular/platform-server": "^
|
|
80
|
-
"@angular/service-worker": "^
|
|
77
|
+
"@angular/compiler-cli": "^18.0.0-next.0",
|
|
78
|
+
"@angular/localize": "^18.0.0-next.0",
|
|
79
|
+
"@angular/platform-server": "^18.0.0-next.0",
|
|
80
|
+
"@angular/service-worker": "^18.0.0-next.0",
|
|
81
81
|
"@web/test-runner": "^0.18.0",
|
|
82
82
|
"browser-sync": "^3.0.2",
|
|
83
83
|
"jest": "^29.5.0",
|
|
84
84
|
"jest-environment-jsdom": "^29.5.0",
|
|
85
85
|
"karma": "^6.3.0",
|
|
86
|
-
"ng-packagr": "^
|
|
86
|
+
"ng-packagr": "^18.0.0-next.0",
|
|
87
87
|
"protractor": "^7.0.0",
|
|
88
88
|
"tailwindcss": "^2.0.0 || ^3.0.0",
|
|
89
|
-
"typescript": ">=5.
|
|
89
|
+
"typescript": ">=5.4 <5.5"
|
|
90
90
|
},
|
|
91
91
|
"peerDependenciesMeta": {
|
|
92
92
|
"@angular/localize": {
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
"url": "https://github.com/angular/angular-cli.git"
|
|
136
136
|
},
|
|
137
137
|
"engines": {
|
|
138
|
-
"node": "^18.
|
|
138
|
+
"node": "^18.19.1 || >=20.11.1",
|
|
139
139
|
"npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
|
|
140
140
|
"yarn": ">= 1.13.0"
|
|
141
141
|
},
|
|
@@ -44,7 +44,7 @@ const spinner_1 = require("../../utils/spinner");
|
|
|
44
44
|
async function _renderUniversal(options, context, browserResult, serverResult, spinner) {
|
|
45
45
|
// Get browser target options.
|
|
46
46
|
const browserTarget = (0, architect_1.targetFromTargetString)(options.browserTarget);
|
|
47
|
-
const rawBrowserOptions =
|
|
47
|
+
const rawBrowserOptions = await context.getTargetOptions(browserTarget);
|
|
48
48
|
const browserBuilderName = await context.getBuilderNameForTarget(browserTarget);
|
|
49
49
|
const browserOptions = await context.validateOptions(rawBrowserOptions, browserBuilderName);
|
|
50
50
|
// Locate zone.js to load in the render worker
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { BuilderOutput } from '@angular-devkit/architect';
|
|
9
|
-
import type { logging } from '@angular-devkit/core';
|
|
8
|
+
import { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
|
|
10
9
|
import { BuildOutputFile } from '../../tools/esbuild/bundler-context';
|
|
11
10
|
import { ExecutionResult, RebuildState } from '../../tools/esbuild/bundler-execution-result';
|
|
12
11
|
import { NormalizedCachedOptions } from '../../utils/normalize-cache';
|
|
@@ -16,7 +15,7 @@ export declare function runEsBuildBuildAction(action: (rebuildState?: RebuildSta
|
|
|
16
15
|
workspaceRoot: string;
|
|
17
16
|
projectRoot: string;
|
|
18
17
|
outputOptions: NormalizedOutputOptions;
|
|
19
|
-
logger:
|
|
18
|
+
logger: BuilderContext['logger'];
|
|
20
19
|
cacheOptions: NormalizedCachedOptions;
|
|
21
20
|
writeToFileSystem: boolean;
|
|
22
21
|
writeToFileSystemFilter: ((file: BuildOutputFile) => boolean) | undefined;
|
|
@@ -99,7 +99,9 @@ export declare function normalizeOptions(context: BuilderContext, projectName: s
|
|
|
99
99
|
sourcemapOptions: import("../..").SourceMapObject;
|
|
100
100
|
tsconfig: string;
|
|
101
101
|
projectRoot: string;
|
|
102
|
-
assets: import("../..").AssetPatternObject
|
|
102
|
+
assets: (import("../..").AssetPatternObject & {
|
|
103
|
+
output: string;
|
|
104
|
+
})[] | undefined;
|
|
103
105
|
outputNames: {
|
|
104
106
|
bundles: string;
|
|
105
107
|
media: string;
|
|
@@ -560,11 +560,12 @@
|
|
|
560
560
|
},
|
|
561
561
|
"output": {
|
|
562
562
|
"type": "string",
|
|
563
|
+
"default": "",
|
|
563
564
|
"description": "Absolute path within the output."
|
|
564
565
|
}
|
|
565
566
|
},
|
|
566
567
|
"additionalProperties": false,
|
|
567
|
-
"required": ["glob", "input"
|
|
568
|
+
"required": ["glob", "input"]
|
|
568
569
|
},
|
|
569
570
|
{
|
|
570
571
|
"type": "string"
|
|
@@ -454,11 +454,12 @@
|
|
|
454
454
|
},
|
|
455
455
|
"output": {
|
|
456
456
|
"type": "string",
|
|
457
|
+
"default": "",
|
|
457
458
|
"description": "Absolute path within the output."
|
|
458
459
|
}
|
|
459
460
|
},
|
|
460
461
|
"additionalProperties": false,
|
|
461
|
-
"required": ["glob", "input"
|
|
462
|
+
"required": ["glob", "input"]
|
|
462
463
|
},
|
|
463
464
|
{
|
|
464
465
|
"type": "string"
|
|
@@ -466,11 +466,12 @@
|
|
|
466
466
|
},
|
|
467
467
|
"output": {
|
|
468
468
|
"type": "string",
|
|
469
|
+
"default": "",
|
|
469
470
|
"description": "Absolute path within the output."
|
|
470
471
|
}
|
|
471
472
|
},
|
|
472
473
|
"additionalProperties": false,
|
|
473
|
-
"required": ["glob", "input"
|
|
474
|
+
"required": ["glob", "input"]
|
|
474
475
|
},
|
|
475
476
|
{
|
|
476
477
|
"type": "string"
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
/// <reference types="node" />
|
|
9
|
-
/// <reference types="@types/node/http" />
|
|
10
|
-
/// <reference types="@types/node/ts4.8/http" />
|
|
11
9
|
import type { BuilderContext } from '@angular-devkit/architect';
|
|
12
10
|
import type { Plugin } from 'esbuild';
|
|
13
11
|
import type http from 'node:http';
|
|
@@ -49,18 +49,25 @@ const supported_browsers_1 = require("../../utils/supported-browsers");
|
|
|
49
49
|
const webpack_browser_config_1 = require("../../utils/webpack-browser-config");
|
|
50
50
|
const application_1 = require("../application");
|
|
51
51
|
const browser_esbuild_1 = require("../browser-esbuild");
|
|
52
|
+
/**
|
|
53
|
+
* Build options that are also present on the dev server but are only passed
|
|
54
|
+
* to the build.
|
|
55
|
+
*/
|
|
56
|
+
const CONVENIENCE_BUILD_OPTIONS = ['watch', 'poll', 'verbose'];
|
|
52
57
|
// eslint-disable-next-line max-lines-per-function
|
|
53
58
|
async function* serveWithVite(serverOptions, builderName, context, transformers, extensions) {
|
|
54
59
|
// Get the browser configuration from the target name.
|
|
55
|
-
const rawBrowserOptions =
|
|
60
|
+
const rawBrowserOptions = await context.getTargetOptions(serverOptions.buildTarget);
|
|
56
61
|
// Deploy url is not used in the dev-server.
|
|
57
62
|
delete rawBrowserOptions.deployUrl;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
// Copy convenience options to build
|
|
64
|
+
for (const optionName of CONVENIENCE_BUILD_OPTIONS) {
|
|
65
|
+
const optionValue = serverOptions[optionName];
|
|
66
|
+
if (optionValue !== undefined) {
|
|
67
|
+
rawBrowserOptions[optionName] = optionValue;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const browserOptions = await context.validateOptions(rawBrowserOptions, builderName);
|
|
64
71
|
if (browserOptions.prerender || browserOptions.ssr) {
|
|
65
72
|
// Disable prerendering if enabled and force SSR.
|
|
66
73
|
// This is so instead of prerendering all the routes for every change, the page is "prerendered" when it is requested.
|
|
@@ -68,7 +68,7 @@ function serveWebpackBrowser(options, builderName, context, transforms = {}) {
|
|
|
68
68
|
See https://webpack.js.org/guides/hot-module-replacement for information on working with HMR for Webpack.`);
|
|
69
69
|
}
|
|
70
70
|
// Get the browser configuration from the target name.
|
|
71
|
-
const rawBrowserOptions =
|
|
71
|
+
const rawBrowserOptions = await context.getTargetOptions(options.buildTarget);
|
|
72
72
|
if (rawBrowserOptions.outputHashing && rawBrowserOptions.outputHashing !== schema_1.OutputHashing.None) {
|
|
73
73
|
// Disable output hashing for dev build as this can cause memory leaks
|
|
74
74
|
// See: https://github.com/webpack/webpack-dev-server/issues/377#issuecomment-241258405
|
|
@@ -290,6 +290,7 @@
|
|
|
290
290
|
},
|
|
291
291
|
"output": {
|
|
292
292
|
"type": "string",
|
|
293
|
+
"default": "",
|
|
293
294
|
"description": "Absolute path within the output."
|
|
294
295
|
},
|
|
295
296
|
"ignore": {
|
|
@@ -301,7 +302,7 @@
|
|
|
301
302
|
}
|
|
302
303
|
},
|
|
303
304
|
"additionalProperties": false,
|
|
304
|
-
"required": ["glob", "input"
|
|
305
|
+
"required": ["glob", "input"]
|
|
305
306
|
},
|
|
306
307
|
{
|
|
307
308
|
"type": "string"
|
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
|
|
9
|
-
import { json } from '@angular-devkit/core';
|
|
10
9
|
import { Schema } from './schema';
|
|
11
|
-
type PrerenderBuilderOptions = Schema
|
|
10
|
+
type PrerenderBuilderOptions = Schema;
|
|
12
11
|
type PrerenderBuilderOutput = BuilderOutput;
|
|
13
12
|
/**
|
|
14
13
|
* Builds the browser and server, then renders each route in options.routes
|
|
@@ -16,5 +15,5 @@ type PrerenderBuilderOutput = BuilderOutput;
|
|
|
16
15
|
* the browser result.
|
|
17
16
|
*/
|
|
18
17
|
export declare function execute(options: PrerenderBuilderOptions, context: BuilderContext): Promise<PrerenderBuilderOutput>;
|
|
19
|
-
declare const _default: import("../../../../architect/src/internal").Builder<Schema &
|
|
18
|
+
declare const _default: import("../../../../architect/src/internal").Builder<Schema & import("../../../../core/src").JsonObject>;
|
|
20
19
|
export default _default;
|
|
@@ -251,11 +251,12 @@
|
|
|
251
251
|
},
|
|
252
252
|
"output": {
|
|
253
253
|
"type": "string",
|
|
254
|
+
"default": "",
|
|
254
255
|
"description": "Absolute path within the output."
|
|
255
256
|
}
|
|
256
257
|
},
|
|
257
258
|
"additionalProperties": false,
|
|
258
|
-
"required": ["glob", "input"
|
|
259
|
+
"required": ["glob", "input"]
|
|
259
260
|
},
|
|
260
261
|
{
|
|
261
262
|
"type": "string"
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
/// <reference types="
|
|
9
|
-
/// <reference types="@types/node/ts4.8/child_process" />
|
|
8
|
+
/// <reference types="node" />
|
|
10
9
|
import { SpawnOptions } from 'child_process';
|
|
11
10
|
import { Observable } from 'rxjs';
|
|
12
11
|
export declare function getAvailablePort(): Promise<number>;
|
|
@@ -269,6 +269,7 @@
|
|
|
269
269
|
},
|
|
270
270
|
"output": {
|
|
271
271
|
"type": "string",
|
|
272
|
+
"default": "",
|
|
272
273
|
"description": "Absolute path within the output."
|
|
273
274
|
},
|
|
274
275
|
"ignore": {
|
|
@@ -280,7 +281,7 @@
|
|
|
280
281
|
}
|
|
281
282
|
},
|
|
282
283
|
"additionalProperties": false,
|
|
283
|
-
"required": ["glob", "input"
|
|
284
|
+
"required": ["glob", "input"]
|
|
284
285
|
},
|
|
285
286
|
{
|
|
286
287
|
"type": "string"
|
|
@@ -315,10 +315,7 @@ function default_1() {
|
|
|
315
315
|
if (!wrapDecorators || visitedClasses.has(classNode)) {
|
|
316
316
|
return;
|
|
317
317
|
}
|
|
318
|
-
if (!
|
|
319
|
-
!parentPath.isVariableDeclarator() ||
|
|
320
|
-
!core_1.types.isIdentifier(parentPath.node.id) ||
|
|
321
|
-
parentPath.node.id.name !== classNode.id.name) {
|
|
318
|
+
if (!parentPath.isVariableDeclarator() || !core_1.types.isIdentifier(parentPath.node.id)) {
|
|
322
319
|
return;
|
|
323
320
|
}
|
|
324
321
|
const origin = parentPath.parentPath;
|
|
@@ -338,10 +335,10 @@ function default_1() {
|
|
|
338
335
|
// Wrap class and safe static assignments in a pure annotated IIFE
|
|
339
336
|
const container = core_1.types.arrowFunctionExpression([], core_1.types.blockStatement([
|
|
340
337
|
core_1.types.variableDeclaration('let', [
|
|
341
|
-
core_1.types.variableDeclarator(core_1.types.cloneNode(
|
|
338
|
+
core_1.types.variableDeclarator(core_1.types.cloneNode(parentPath.node.id), classNode),
|
|
342
339
|
]),
|
|
343
340
|
...wrapStatementNodes,
|
|
344
|
-
core_1.types.returnStatement(core_1.types.cloneNode(
|
|
341
|
+
core_1.types.returnStatement(core_1.types.cloneNode(parentPath.node.id)),
|
|
345
342
|
]));
|
|
346
343
|
const replacementInitializer = core_1.types.callExpression(core_1.types.parenthesizedExpression(container), []);
|
|
347
344
|
(0, helper_annotate_as_pure_1.default)(replacementInitializer);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
export { default as adjustStaticMembers } from './adjust-static-class-members';
|
|
9
|
+
export { default as adjustTypeScriptEnums } from './adjust-typescript-enums';
|
|
10
|
+
export { default as elideAngularMetadata } from './elide-angular-metadata';
|
|
11
|
+
export { default as markTopLevelPure } from './pure-toplevel-functions';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.markTopLevelPure = exports.elideAngularMetadata = exports.adjustTypeScriptEnums = exports.adjustStaticMembers = void 0;
|
|
14
|
+
var adjust_static_class_members_1 = require("./adjust-static-class-members");
|
|
15
|
+
Object.defineProperty(exports, "adjustStaticMembers", { enumerable: true, get: function () { return __importDefault(adjust_static_class_members_1).default; } });
|
|
16
|
+
var adjust_typescript_enums_1 = require("./adjust-typescript-enums");
|
|
17
|
+
Object.defineProperty(exports, "adjustTypeScriptEnums", { enumerable: true, get: function () { return __importDefault(adjust_typescript_enums_1).default; } });
|
|
18
|
+
var elide_angular_metadata_1 = require("./elide-angular-metadata");
|
|
19
|
+
Object.defineProperty(exports, "elideAngularMetadata", { enumerable: true, get: function () { return __importDefault(elide_angular_metadata_1).default; } });
|
|
20
|
+
var pure_toplevel_functions_1 = require("./pure-toplevel-functions");
|
|
21
|
+
Object.defineProperty(exports, "markTopLevelPure", { enumerable: true, get: function () { return __importDefault(pure_toplevel_functions_1).default; } });
|
|
@@ -147,11 +147,12 @@ function default_1(api, options) {
|
|
|
147
147
|
needRuntimeTransform = true;
|
|
148
148
|
}
|
|
149
149
|
if (options.optimize) {
|
|
150
|
+
const { adjustStaticMembers, adjustTypeScriptEnums, elideAngularMetadata, markTopLevelPure, } = require('../plugins');
|
|
150
151
|
if (options.optimize.pureTopLevel) {
|
|
151
|
-
plugins.push(
|
|
152
|
+
plugins.push(markTopLevelPure);
|
|
152
153
|
}
|
|
153
|
-
plugins.push(
|
|
154
|
-
|
|
154
|
+
plugins.push(elideAngularMetadata, adjustTypeScriptEnums, [
|
|
155
|
+
adjustStaticMembers,
|
|
155
156
|
{ wrapDecorators: options.optimize.wrapDecorators },
|
|
156
157
|
]);
|
|
157
158
|
}
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
/// <reference types="node" />
|
|
9
|
-
/// <reference types="@types/node/worker_threads" />
|
|
10
|
-
/// <reference types="@types/node/ts4.8/worker_threads" />
|
|
11
9
|
import type { PartialMessage } from 'esbuild';
|
|
12
10
|
import { type MessagePort } from 'node:worker_threads';
|
|
13
11
|
import type { DiagnosticModes } from './angular-compilation';
|
|
@@ -34,8 +34,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
34
34
|
};
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const core_1 = require("@babel/core");
|
|
37
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
38
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
37
39
|
const piscina_1 = __importDefault(require("piscina"));
|
|
38
|
-
const application_1 = __importStar(require("../../tools/babel/presets/application"));
|
|
39
40
|
const load_esm_1 = require("../../utils/load-esm");
|
|
40
41
|
const textDecoder = new TextDecoder();
|
|
41
42
|
const textEncoder = new TextEncoder();
|
|
@@ -47,22 +48,41 @@ async function transformJavaScript(request) {
|
|
|
47
48
|
return piscina_1.default.move(textEncoder.encode(transformedData));
|
|
48
49
|
}
|
|
49
50
|
exports.default = transformJavaScript;
|
|
51
|
+
/**
|
|
52
|
+
* Cached instance of the compiler-cli linker's createEs2015LinkerPlugin function.
|
|
53
|
+
*/
|
|
50
54
|
let linkerPluginCreator;
|
|
55
|
+
/**
|
|
56
|
+
* Cached instance of the compiler-cli linker's needsLinking function.
|
|
57
|
+
*/
|
|
58
|
+
let needsLinking;
|
|
51
59
|
async function transformWithBabel(filename, data, options) {
|
|
52
|
-
const shouldLink = !options.skipLinker && (await
|
|
60
|
+
const shouldLink = !options.skipLinker && (await requiresLinking(filename, data));
|
|
53
61
|
const useInputSourcemap = options.sourcemap &&
|
|
54
62
|
(!!options.thirdPartySourcemaps || !/[\\/]node_modules[\\/]/.test(filename));
|
|
63
|
+
const plugins = [];
|
|
64
|
+
// Lazy load the linker plugin only when linking is required
|
|
65
|
+
if (shouldLink) {
|
|
66
|
+
const linkerPlugin = await createLinkerPlugin(options);
|
|
67
|
+
plugins.push(linkerPlugin);
|
|
68
|
+
}
|
|
69
|
+
if (options.advancedOptimizations) {
|
|
70
|
+
const sideEffectFree = options.sideEffects === false;
|
|
71
|
+
const safeAngularPackage = sideEffectFree && /[\\/]node_modules[\\/]@angular[\\/]/.test(filename);
|
|
72
|
+
const { adjustStaticMembers, adjustTypeScriptEnums, elideAngularMetadata, markTopLevelPure } = await Promise.resolve().then(() => __importStar(require('../babel/plugins')));
|
|
73
|
+
if (safeAngularPackage) {
|
|
74
|
+
plugins.push(markTopLevelPure);
|
|
75
|
+
}
|
|
76
|
+
plugins.push(elideAngularMetadata, adjustTypeScriptEnums, [
|
|
77
|
+
adjustStaticMembers,
|
|
78
|
+
{ wrapDecorators: sideEffectFree },
|
|
79
|
+
]);
|
|
80
|
+
}
|
|
55
81
|
// If no additional transformations are needed, return the data directly
|
|
56
|
-
if (
|
|
82
|
+
if (plugins.length === 0) {
|
|
57
83
|
// Strip sourcemaps if they should not be used
|
|
58
84
|
return useInputSourcemap ? data : data.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, '');
|
|
59
85
|
}
|
|
60
|
-
const sideEffectFree = options.sideEffects === false;
|
|
61
|
-
const safeAngularPackage = sideEffectFree && /[\\/]node_modules[\\/]@angular[\\/]/.test(filename);
|
|
62
|
-
// Lazy load the linker plugin only when linking is required
|
|
63
|
-
if (shouldLink) {
|
|
64
|
-
linkerPluginCreator ??= (await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker/babel')).createEs2015LinkerPlugin;
|
|
65
|
-
}
|
|
66
86
|
const result = await (0, core_1.transformAsync)(data, {
|
|
67
87
|
filename,
|
|
68
88
|
inputSourceMap: (useInputSourcemap ? undefined : false),
|
|
@@ -71,23 +91,7 @@ async function transformWithBabel(filename, data, options) {
|
|
|
71
91
|
configFile: false,
|
|
72
92
|
babelrc: false,
|
|
73
93
|
browserslistConfigFile: false,
|
|
74
|
-
plugins
|
|
75
|
-
presets: [
|
|
76
|
-
[
|
|
77
|
-
application_1.default,
|
|
78
|
-
{
|
|
79
|
-
angularLinker: linkerPluginCreator && {
|
|
80
|
-
shouldLink,
|
|
81
|
-
jitMode: options.jit,
|
|
82
|
-
linkerPluginCreator,
|
|
83
|
-
},
|
|
84
|
-
optimize: options.advancedOptimizations && {
|
|
85
|
-
pureTopLevel: safeAngularPackage,
|
|
86
|
-
wrapDecorators: sideEffectFree,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
],
|
|
94
|
+
plugins,
|
|
91
95
|
});
|
|
92
96
|
const outputCode = result?.code ?? data;
|
|
93
97
|
// Strip sourcemaps if they should not be used.
|
|
@@ -96,3 +100,55 @@ async function transformWithBabel(filename, data, options) {
|
|
|
96
100
|
? outputCode
|
|
97
101
|
: outputCode.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, '');
|
|
98
102
|
}
|
|
103
|
+
async function requiresLinking(path, source) {
|
|
104
|
+
// @angular/core and @angular/compiler will cause false positives
|
|
105
|
+
// Also, TypeScript files do not require linking
|
|
106
|
+
if (/[\\/]@angular[\\/](?:compiler|core)|\.tsx?$/.test(path)) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
if (!needsLinking) {
|
|
110
|
+
// Load ESM `@angular/compiler-cli/linker` using the TypeScript dynamic import workaround.
|
|
111
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
112
|
+
// changed to a direct dynamic import.
|
|
113
|
+
const linkerModule = await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker');
|
|
114
|
+
needsLinking = linkerModule.needsLinking;
|
|
115
|
+
}
|
|
116
|
+
return needsLinking(path, source);
|
|
117
|
+
}
|
|
118
|
+
async function createLinkerPlugin(options) {
|
|
119
|
+
linkerPluginCreator ??= (await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker/babel')).createEs2015LinkerPlugin;
|
|
120
|
+
const linkerPlugin = linkerPluginCreator({
|
|
121
|
+
linkerJitMode: options.jit,
|
|
122
|
+
// This is a workaround until https://github.com/angular/angular/issues/42769 is fixed.
|
|
123
|
+
sourceMapping: false,
|
|
124
|
+
logger: {
|
|
125
|
+
level: 1, // Info level
|
|
126
|
+
debug(...args) {
|
|
127
|
+
// eslint-disable-next-line no-console
|
|
128
|
+
console.debug(args);
|
|
129
|
+
},
|
|
130
|
+
info(...args) {
|
|
131
|
+
// eslint-disable-next-line no-console
|
|
132
|
+
console.info(args);
|
|
133
|
+
},
|
|
134
|
+
warn(...args) {
|
|
135
|
+
// eslint-disable-next-line no-console
|
|
136
|
+
console.warn(args);
|
|
137
|
+
},
|
|
138
|
+
error(...args) {
|
|
139
|
+
// eslint-disable-next-line no-console
|
|
140
|
+
console.error(args);
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
fileSystem: {
|
|
144
|
+
resolve: node_path_1.default.resolve,
|
|
145
|
+
exists: node_fs_1.default.existsSync,
|
|
146
|
+
dirname: node_path_1.default.dirname,
|
|
147
|
+
relative: node_path_1.default.relative,
|
|
148
|
+
readFile: node_fs_1.default.readFileSync,
|
|
149
|
+
// Node.JS types don't overlap the Compiler types.
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
return linkerPlugin;
|
|
154
|
+
}
|