@angular/build 18.0.0-next.3
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/LICENSE +21 -0
- package/README.md +5 -0
- package/builders.json +14 -0
- package/package.json +87 -0
- package/src/builders/application/build-action.d.ts +33 -0
- package/src/builders/application/build-action.js +183 -0
- package/src/builders/application/execute-build.d.ts +11 -0
- package/src/builders/application/execute-build.js +125 -0
- package/src/builders/application/execute-post-bundle.d.ts +25 -0
- package/src/builders/application/execute-post-bundle.js +93 -0
- package/src/builders/application/i18n.d.ts +29 -0
- package/src/builders/application/i18n.js +128 -0
- package/src/builders/application/index.d.ts +57 -0
- package/src/builders/application/index.js +121 -0
- package/src/builders/application/options.d.ts +149 -0
- package/src/builders/application/options.js +369 -0
- package/src/builders/application/schema.d.ts +512 -0
- package/src/builders/application/schema.js +58 -0
- package/src/builders/application/schema.json +635 -0
- package/src/builders/application/setup-bundling.d.ts +19 -0
- package/src/builders/application/setup-bundling.js +71 -0
- package/src/builders/dev-server/builder.d.ts +32 -0
- package/src/builders/dev-server/builder.js +70 -0
- package/src/builders/dev-server/index.d.ts +14 -0
- package/src/builders/dev-server/index.js +15 -0
- package/src/builders/dev-server/internal.d.ts +19 -0
- package/src/builders/dev-server/internal.js +29 -0
- package/src/builders/dev-server/options.d.ts +47 -0
- package/src/builders/dev-server/options.js +65 -0
- package/src/builders/dev-server/output.d.ts +16 -0
- package/src/builders/dev-server/output.js +9 -0
- package/src/builders/dev-server/schema.d.ts +118 -0
- package/src/builders/dev-server/schema.js +4 -0
- package/src/builders/dev-server/schema.json +131 -0
- package/src/builders/dev-server/vite-server.d.ts +31 -0
- package/src/builders/dev-server/vite-server.js +504 -0
- package/src/index.d.ts +11 -0
- package/src/index.js +16 -0
- package/src/private.d.ts +35 -0
- package/src/private.js +70 -0
- package/src/tools/babel/plugins/adjust-static-class-members.d.ts +26 -0
- package/src/tools/babel/plugins/adjust-static-class-members.js +351 -0
- package/src/tools/babel/plugins/adjust-typescript-enums.d.ts +22 -0
- package/src/tools/babel/plugins/adjust-typescript-enums.js +113 -0
- package/src/tools/babel/plugins/elide-angular-metadata.d.ts +22 -0
- package/src/tools/babel/plugins/elide-angular-metadata.js +110 -0
- package/src/tools/babel/plugins/index.d.ts +11 -0
- package/src/tools/babel/plugins/index.js +21 -0
- package/src/tools/babel/plugins/pure-toplevel-functions.d.ts +15 -0
- package/src/tools/babel/plugins/pure-toplevel-functions.js +90 -0
- package/src/tools/babel/typings.d.ts +21 -0
- package/src/tools/esbuild/angular/angular-host.d.ts +26 -0
- package/src/tools/esbuild/angular/angular-host.js +134 -0
- package/src/tools/esbuild/angular/compilation/angular-compilation.d.ts +42 -0
- package/src/tools/esbuild/angular/compilation/angular-compilation.js +94 -0
- package/src/tools/esbuild/angular/compilation/aot-compilation.d.ts +21 -0
- package/src/tools/esbuild/angular/compilation/aot-compilation.js +224 -0
- package/src/tools/esbuild/angular/compilation/factory.d.ts +16 -0
- package/src/tools/esbuild/angular/compilation/factory.js +56 -0
- package/src/tools/esbuild/angular/compilation/index.d.ts +10 -0
- package/src/tools/esbuild/angular/compilation/index.js +17 -0
- package/src/tools/esbuild/angular/compilation/jit-bootstrap-transformer.d.ts +10 -0
- package/src/tools/esbuild/angular/compilation/jit-bootstrap-transformer.js +182 -0
- package/src/tools/esbuild/angular/compilation/jit-compilation.d.ts +21 -0
- package/src/tools/esbuild/angular/compilation/jit-compilation.js +106 -0
- package/src/tools/esbuild/angular/compilation/noop-compilation.d.ts +20 -0
- package/src/tools/esbuild/angular/compilation/noop-compilation.js +26 -0
- package/src/tools/esbuild/angular/compilation/parallel-compilation.d.ts +42 -0
- package/src/tools/esbuild/angular/compilation/parallel-compilation.js +123 -0
- package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +33 -0
- package/src/tools/esbuild/angular/compilation/parallel-worker.js +90 -0
- package/src/tools/esbuild/angular/compilation-state.d.ts +15 -0
- package/src/tools/esbuild/angular/compilation-state.js +44 -0
- package/src/tools/esbuild/angular/compiler-plugin.d.ts +27 -0
- package/src/tools/esbuild/angular/compiler-plugin.js +441 -0
- package/src/tools/esbuild/angular/component-stylesheets.d.ts +44 -0
- package/src/tools/esbuild/angular/component-stylesheets.js +150 -0
- package/src/tools/esbuild/angular/diagnostics.d.ts +15 -0
- package/src/tools/esbuild/angular/diagnostics.js +69 -0
- package/src/tools/esbuild/angular/file-reference-tracker.d.ts +17 -0
- package/src/tools/esbuild/angular/file-reference-tracker.js +57 -0
- package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +23 -0
- package/src/tools/esbuild/angular/jit-plugin-callbacks.js +117 -0
- package/src/tools/esbuild/angular/jit-resource-transformer.d.ts +17 -0
- package/src/tools/esbuild/angular/jit-resource-transformer.js +186 -0
- package/src/tools/esbuild/angular/source-file-cache.d.ts +18 -0
- package/src/tools/esbuild/angular/source-file-cache.js +65 -0
- package/src/tools/esbuild/angular/uri.d.ts +54 -0
- package/src/tools/esbuild/angular/uri.js +74 -0
- package/src/tools/esbuild/angular/web-worker-transformer.d.ts +17 -0
- package/src/tools/esbuild/angular/web-worker-transformer.js +94 -0
- package/src/tools/esbuild/application-code-bundle.d.ts +20 -0
- package/src/tools/esbuild/application-code-bundle.js +368 -0
- package/src/tools/esbuild/budget-stats.d.ts +19 -0
- package/src/tools/esbuild/budget-stats.js +59 -0
- package/src/tools/esbuild/bundler-context.d.ts +75 -0
- package/src/tools/esbuild/bundler-context.js +366 -0
- package/src/tools/esbuild/bundler-execution-result.d.ts +71 -0
- package/src/tools/esbuild/bundler-execution-result.js +131 -0
- package/src/tools/esbuild/cache.d.ts +88 -0
- package/src/tools/esbuild/cache.js +92 -0
- package/src/tools/esbuild/commonjs-checker.d.ts +28 -0
- package/src/tools/esbuild/commonjs-checker.js +151 -0
- package/src/tools/esbuild/compiler-plugin-options.d.ts +16 -0
- package/src/tools/esbuild/compiler-plugin-options.js +49 -0
- package/src/tools/esbuild/external-packages-plugin.d.ts +18 -0
- package/src/tools/esbuild/external-packages-plugin.js +70 -0
- package/src/tools/esbuild/global-scripts.d.ts +16 -0
- package/src/tools/esbuild/global-scripts.js +142 -0
- package/src/tools/esbuild/global-styles.d.ts +10 -0
- package/src/tools/esbuild/global-styles.js +74 -0
- package/src/tools/esbuild/i18n-inliner-worker.d.ts +42 -0
- package/src/tools/esbuild/i18n-inliner-worker.js +136 -0
- package/src/tools/esbuild/i18n-inliner.d.ts +44 -0
- package/src/tools/esbuild/i18n-inliner.js +150 -0
- package/src/tools/esbuild/i18n-locale-plugin.d.ts +22 -0
- package/src/tools/esbuild/i18n-locale-plugin.js +120 -0
- package/src/tools/esbuild/index-html-generator.d.ts +15 -0
- package/src/tools/esbuild/index-html-generator.js +81 -0
- package/src/tools/esbuild/javascript-transformer-worker.d.ts +19 -0
- package/src/tools/esbuild/javascript-transformer-worker.js +154 -0
- package/src/tools/esbuild/javascript-transformer.d.ts +54 -0
- package/src/tools/esbuild/javascript-transformer.js +147 -0
- package/src/tools/esbuild/license-extractor.d.ts +25 -0
- package/src/tools/esbuild/license-extractor.js +158 -0
- package/src/tools/esbuild/load-result-cache.d.ts +21 -0
- package/src/tools/esbuild/load-result-cache.js +75 -0
- package/src/tools/esbuild/profiling.d.ts +11 -0
- package/src/tools/esbuild/profiling.js +78 -0
- package/src/tools/esbuild/rxjs-esm-resolution-plugin.d.ts +18 -0
- package/src/tools/esbuild/rxjs-esm-resolution-plugin.js +44 -0
- package/src/tools/esbuild/sourcemap-ignorelist-plugin.d.ts +17 -0
- package/src/tools/esbuild/sourcemap-ignorelist-plugin.js +73 -0
- package/src/tools/esbuild/stylesheets/bundle-options.d.ts +35 -0
- package/src/tools/esbuild/stylesheets/bundle-options.js +64 -0
- package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.d.ts +25 -0
- package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +57 -0
- package/src/tools/esbuild/stylesheets/css-language.d.ts +9 -0
- package/src/tools/esbuild/stylesheets/css-language.js +15 -0
- package/src/tools/esbuild/stylesheets/css-resource-plugin.d.ts +18 -0
- package/src/tools/esbuild/stylesheets/css-resource-plugin.js +114 -0
- package/src/tools/esbuild/stylesheets/less-language.d.ts +9 -0
- package/src/tools/esbuild/stylesheets/less-language.js +155 -0
- package/src/tools/esbuild/stylesheets/sass-language.d.ts +10 -0
- package/src/tools/esbuild/stylesheets/sass-language.js +185 -0
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.d.ts +58 -0
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +282 -0
- package/src/tools/esbuild/utils.d.ts +49 -0
- package/src/tools/esbuild/utils.js +392 -0
- package/src/tools/esbuild/virtual-module-plugin.d.ts +33 -0
- package/src/tools/esbuild/virtual-module-plugin.js +43 -0
- package/src/tools/esbuild/watcher.d.ts +25 -0
- package/src/tools/esbuild/watcher.js +118 -0
- package/src/tools/sass/lexer.d.ts +18 -0
- package/src/tools/sass/lexer.js +161 -0
- package/src/tools/sass/rebasing-importer.d.ts +101 -0
- package/src/tools/sass/rebasing-importer.js +334 -0
- package/src/tools/sass/sass-service.d.ts +72 -0
- package/src/tools/sass/sass-service.js +213 -0
- package/src/tools/sass/worker.d.ts +8 -0
- package/src/tools/sass/worker.js +192 -0
- package/src/tools/vite/angular-memory-plugin.d.ts +24 -0
- package/src/tools/vite/angular-memory-plugin.js +268 -0
- package/src/tools/vite/i18n-locale-plugin.d.ts +18 -0
- package/src/tools/vite/i18n-locale-plugin.js +55 -0
- package/src/utils/bundle-calculator.d.ts +44 -0
- package/src/utils/bundle-calculator.js +303 -0
- package/src/utils/check-port.d.ts +8 -0
- package/src/utils/check-port.js +58 -0
- package/src/utils/color.d.ts +10 -0
- package/src/utils/color.js +63 -0
- package/src/utils/delete-output-dir.d.ts +11 -0
- package/src/utils/delete-output-dir.js +46 -0
- package/src/utils/environment-options.d.ts +16 -0
- package/src/utils/environment-options.js +79 -0
- package/src/utils/error.d.ts +10 -0
- package/src/utils/error.js +21 -0
- package/src/utils/format-bytes.d.ts +8 -0
- package/src/utils/format-bytes.js +22 -0
- package/src/utils/i18n-options.d.ts +33 -0
- package/src/utils/i18n-options.js +161 -0
- package/src/utils/index-file/add-event-dispatch-contract.d.ts +8 -0
- package/src/utils/index-file/add-event-dispatch-contract.js +28 -0
- package/src/utils/index-file/augment-index-html.d.ts +40 -0
- package/src/utils/index-file/augment-index-html.js +239 -0
- package/src/utils/index-file/html-rewriting-stream.d.ts +11 -0
- package/src/utils/index-file/html-rewriting-stream.js +28 -0
- package/src/utils/index-file/index-html-generator.d.ts +57 -0
- package/src/utils/index-file/index-html-generator.js +135 -0
- package/src/utils/index-file/inline-critical-css.d.ts +24 -0
- package/src/utils/index-file/inline-critical-css.js +179 -0
- package/src/utils/index-file/inline-fonts.d.ts +23 -0
- package/src/utils/index-file/inline-fonts.js +267 -0
- package/src/utils/index-file/nonce.d.ts +12 -0
- package/src/utils/index-file/nonce.js +55 -0
- package/src/utils/index-file/style-nonce.d.ts +12 -0
- package/src/utils/index-file/style-nonce.js +55 -0
- package/src/utils/index.d.ts +11 -0
- package/src/utils/index.js +27 -0
- package/src/utils/load-esm.d.ts +20 -0
- package/src/utils/load-esm.js +31 -0
- package/src/utils/load-proxy-config.d.ts +8 -0
- package/src/utils/load-proxy-config.js +189 -0
- package/src/utils/load-translations.d.ts +16 -0
- package/src/utils/load-translations.js +84 -0
- package/src/utils/normalize-asset-patterns.d.ts +14 -0
- package/src/utils/normalize-asset-patterns.js +96 -0
- package/src/utils/normalize-cache.d.ts +16 -0
- package/src/utils/normalize-cache.js +44 -0
- package/src/utils/normalize-optimization.d.ts +13 -0
- package/src/utils/normalize-optimization.js +42 -0
- package/src/utils/normalize-source-maps.d.ts +9 -0
- package/src/utils/normalize-source-maps.js +23 -0
- package/src/utils/postcss-configuration.d.ts +17 -0
- package/src/utils/postcss-configuration.js +86 -0
- package/src/utils/purge-cache.d.ts +10 -0
- package/src/utils/purge-cache.js +40 -0
- package/src/utils/resolve-assets.d.ts +18 -0
- package/src/utils/resolve-assets.js +35 -0
- package/src/utils/routes-extractor/extractor.d.ts +15 -0
- package/src/utils/routes-extractor/extractor.js +97 -0
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.d.ts +18 -0
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +129 -0
- package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.d.ts +8 -0
- package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js +13 -0
- package/src/utils/server-rendering/fetch-patch.d.ts +8 -0
- package/src/utils/server-rendering/fetch-patch.js +66 -0
- package/src/utils/server-rendering/load-esm-from-memory.d.ts +10 -0
- package/src/utils/server-rendering/load-esm-from-memory.js +26 -0
- package/src/utils/server-rendering/main-bundle-exports.d.ts +27 -0
- package/src/utils/server-rendering/main-bundle-exports.js +9 -0
- package/src/utils/server-rendering/prerender.d.ts +23 -0
- package/src/utils/server-rendering/prerender.js +192 -0
- package/src/utils/server-rendering/render-page.d.ts +26 -0
- package/src/utils/server-rendering/render-page.js +110 -0
- package/src/utils/server-rendering/render-worker.d.ts +22 -0
- package/src/utils/server-rendering/render-worker.js +30 -0
- package/src/utils/server-rendering/routes-extractor-worker.d.ts +21 -0
- package/src/utils/server-rendering/routes-extractor-worker.js +53 -0
- package/src/utils/service-worker.d.ts +25 -0
- package/src/utils/service-worker.js +211 -0
- package/src/utils/spinner.d.ts +20 -0
- package/src/utils/spinner.js +55 -0
- package/src/utils/stats-table.d.ts +20 -0
- package/src/utils/stats-table.js +205 -0
- package/src/utils/supported-browsers.d.ts +10 -0
- package/src/utils/supported-browsers.js +42 -0
- package/src/utils/tty.d.ts +8 -0
- package/src/utils/tty.js +23 -0
- package/src/utils/url.d.ts +8 -0
- package/src/utils/url.js +18 -0
- package/src/utils/version.d.ts +8 -0
- package/src/utils/version.js +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Google, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Angular Build System for Applications and Libraries
|
|
2
|
+
|
|
3
|
+
The sources for this package are in the [Angular CLI](https://github.com/angular/angular-cli) repository. Please file issues and pull requests against that repository.
|
|
4
|
+
|
|
5
|
+
Usage information and reference details can be found in repository [README](../../../README.md) file.
|
package/builders.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"builders": {
|
|
3
|
+
"application": {
|
|
4
|
+
"implementation": "./src/builders/application/index",
|
|
5
|
+
"schema": "./src/builders/application/schema.json",
|
|
6
|
+
"description": "Build an application."
|
|
7
|
+
},
|
|
8
|
+
"dev-server": {
|
|
9
|
+
"implementation": "./src/builders/dev-server/index",
|
|
10
|
+
"schema": "./src/builders/dev-server/schema.json",
|
|
11
|
+
"description": "Execute a development server for an application."
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@angular/build",
|
|
3
|
+
"version": "18.0.0-next.3",
|
|
4
|
+
"description": "Official build system for Angular",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Angular CLI",
|
|
7
|
+
"Angular DevKit",
|
|
8
|
+
"angular",
|
|
9
|
+
"angular-cli",
|
|
10
|
+
"devkit",
|
|
11
|
+
"sdk"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./src/index.d.ts",
|
|
16
|
+
"default": "./src/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./private": {
|
|
19
|
+
"default": "./src/private.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"builders": "builders.json",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@ampproject/remapping": "2.3.0",
|
|
26
|
+
"@angular-devkit/architect": "0.1800.0-next.3",
|
|
27
|
+
"@babel/core": "7.24.4",
|
|
28
|
+
"@babel/helper-annotate-as-pure": "7.22.5",
|
|
29
|
+
"@babel/helper-split-export-declaration": "7.22.6",
|
|
30
|
+
"@vitejs/plugin-basic-ssl": "1.1.0",
|
|
31
|
+
"browserslist": "^4.23.0",
|
|
32
|
+
"critters": "0.0.22",
|
|
33
|
+
"esbuild": "0.20.2",
|
|
34
|
+
"fast-glob": "3.3.2",
|
|
35
|
+
"https-proxy-agent": "7.0.4",
|
|
36
|
+
"inquirer": "9.2.19",
|
|
37
|
+
"less": "4.2.0",
|
|
38
|
+
"magic-string": "0.30.10",
|
|
39
|
+
"mrmime": "2.0.0",
|
|
40
|
+
"ora": "5.4.1",
|
|
41
|
+
"piscina": "4.4.0",
|
|
42
|
+
"parse5-html-rewriting-stream": "7.0.0",
|
|
43
|
+
"postcss": "8.4.38",
|
|
44
|
+
"sass": "1.75.0",
|
|
45
|
+
"semver": "7.6.0",
|
|
46
|
+
"undici": "6.14.1",
|
|
47
|
+
"vite": "5.2.10",
|
|
48
|
+
"watchpack": "2.4.1"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@angular/compiler-cli": "^18.0.0 || ^18.0.0-next.0",
|
|
52
|
+
"@angular/localize": "^18.0.0 || ^18.0.0-next.0",
|
|
53
|
+
"@angular/platform-server": "^18.0.0 || ^18.0.0-next.0",
|
|
54
|
+
"@angular/service-worker": "^18.0.0 || ^18.0.0-next.0",
|
|
55
|
+
"tailwindcss": "^2.0.0 || ^3.0.0",
|
|
56
|
+
"typescript": ">=5.4 <5.5"
|
|
57
|
+
},
|
|
58
|
+
"peerDependenciesMeta": {
|
|
59
|
+
"@angular/localize": {
|
|
60
|
+
"optional": true
|
|
61
|
+
},
|
|
62
|
+
"@angular/platform-server": {
|
|
63
|
+
"optional": true
|
|
64
|
+
},
|
|
65
|
+
"@angular/service-worker": {
|
|
66
|
+
"optional": true
|
|
67
|
+
},
|
|
68
|
+
"tailwindcss": {
|
|
69
|
+
"optional": true
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"repository": {
|
|
73
|
+
"type": "git",
|
|
74
|
+
"url": "https://github.com/angular/angular-cli.git"
|
|
75
|
+
},
|
|
76
|
+
"engines": {
|
|
77
|
+
"node": "^18.19.1 || >=20.11.1",
|
|
78
|
+
"npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
|
|
79
|
+
"yarn": ">= 1.13.0"
|
|
80
|
+
},
|
|
81
|
+
"author": "Angular Authors",
|
|
82
|
+
"license": "MIT",
|
|
83
|
+
"bugs": {
|
|
84
|
+
"url": "https://github.com/angular/angular-cli/issues"
|
|
85
|
+
},
|
|
86
|
+
"homepage": "https://github.com/angular/angular-cli"
|
|
87
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
import { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
|
|
9
|
+
import { BuildOutputFile } from '../../tools/esbuild/bundler-context';
|
|
10
|
+
import { ExecutionResult, RebuildState } from '../../tools/esbuild/bundler-execution-result';
|
|
11
|
+
import { NormalizedCachedOptions } from '../../utils/normalize-cache';
|
|
12
|
+
import { NormalizedOutputOptions } from './options';
|
|
13
|
+
type BuildActionOutput = (ExecutionResult['outputWithFiles'] | ExecutionResult['output']) & BuilderOutput;
|
|
14
|
+
export declare function runEsBuildBuildAction(action: (rebuildState?: RebuildState) => Promise<ExecutionResult>, options: {
|
|
15
|
+
workspaceRoot: string;
|
|
16
|
+
projectRoot: string;
|
|
17
|
+
outputOptions: NormalizedOutputOptions;
|
|
18
|
+
logger: BuilderContext['logger'];
|
|
19
|
+
cacheOptions: NormalizedCachedOptions;
|
|
20
|
+
writeToFileSystem: boolean;
|
|
21
|
+
writeToFileSystemFilter: ((file: BuildOutputFile) => boolean) | undefined;
|
|
22
|
+
watch?: boolean;
|
|
23
|
+
verbose?: boolean;
|
|
24
|
+
progress?: boolean;
|
|
25
|
+
deleteOutputPath?: boolean;
|
|
26
|
+
poll?: number;
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
preserveSymlinks?: boolean;
|
|
29
|
+
clearScreen?: boolean;
|
|
30
|
+
colors?: boolean;
|
|
31
|
+
jsonLogs?: boolean;
|
|
32
|
+
}): AsyncIterable<BuildActionOutput>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,183 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.runEsBuildBuildAction = void 0;
|
|
37
|
+
const node_fs_1 = require("node:fs");
|
|
38
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
39
|
+
const sass_language_1 = require("../../tools/esbuild/stylesheets/sass-language");
|
|
40
|
+
const utils_1 = require("../../tools/esbuild/utils");
|
|
41
|
+
const delete_output_dir_1 = require("../../utils/delete-output-dir");
|
|
42
|
+
const environment_options_1 = require("../../utils/environment-options");
|
|
43
|
+
// Watch workspace for package manager changes
|
|
44
|
+
const packageWatchFiles = [
|
|
45
|
+
// manifest can affect module resolution
|
|
46
|
+
'package.json',
|
|
47
|
+
// npm lock file
|
|
48
|
+
'package-lock.json',
|
|
49
|
+
// pnpm lock file
|
|
50
|
+
'pnpm-lock.yaml',
|
|
51
|
+
// yarn lock file including Yarn PnP manifest files (https://yarnpkg.com/advanced/pnp-spec/)
|
|
52
|
+
'yarn.lock',
|
|
53
|
+
'.pnp.cjs',
|
|
54
|
+
'.pnp.data.json',
|
|
55
|
+
];
|
|
56
|
+
async function* runEsBuildBuildAction(action, options) {
|
|
57
|
+
const { writeToFileSystemFilter, writeToFileSystem, watch, poll, clearScreen, logger, deleteOutputPath, cacheOptions, outputOptions, verbose, projectRoot, workspaceRoot, progress, preserveSymlinks, colors, jsonLogs, } = options;
|
|
58
|
+
if (deleteOutputPath && writeToFileSystem) {
|
|
59
|
+
await (0, delete_output_dir_1.deleteOutputDir)(workspaceRoot, outputOptions.base, [
|
|
60
|
+
outputOptions.browser,
|
|
61
|
+
outputOptions.server,
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
64
|
+
const withProgress = progress ? utils_1.withSpinner : utils_1.withNoProgress;
|
|
65
|
+
// Initial build
|
|
66
|
+
let result;
|
|
67
|
+
try {
|
|
68
|
+
// Perform the build action
|
|
69
|
+
result = await withProgress('Building...', () => action());
|
|
70
|
+
// Log all diagnostic (error/warning/logs) messages
|
|
71
|
+
await (0, utils_1.logMessages)(logger, result, colors, jsonLogs);
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
// Ensure Sass workers are shutdown if not watching
|
|
75
|
+
if (!watch) {
|
|
76
|
+
(0, sass_language_1.shutdownSassWorkerPool)();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Setup watcher if watch mode enabled
|
|
80
|
+
let watcher;
|
|
81
|
+
if (watch) {
|
|
82
|
+
if (progress) {
|
|
83
|
+
logger.info('Watch mode enabled. Watching for file changes...');
|
|
84
|
+
}
|
|
85
|
+
const ignored = [
|
|
86
|
+
// Ignore the output and cache paths to avoid infinite rebuild cycles
|
|
87
|
+
outputOptions.base,
|
|
88
|
+
cacheOptions.basePath,
|
|
89
|
+
`${workspaceRoot.replace(/\\/g, '/')}/**/.*/**`,
|
|
90
|
+
];
|
|
91
|
+
if (!preserveSymlinks) {
|
|
92
|
+
// Ignore all node modules directories to avoid excessive file watchers.
|
|
93
|
+
// Package changes are handled below by watching manifest and lock files.
|
|
94
|
+
// NOTE: this is not enable when preserveSymlinks is true as this would break `npm link` usages.
|
|
95
|
+
ignored.push('**/node_modules/**');
|
|
96
|
+
}
|
|
97
|
+
// Setup a watcher
|
|
98
|
+
const { createWatcher } = await Promise.resolve().then(() => __importStar(require('../../tools/esbuild/watcher')));
|
|
99
|
+
watcher = createWatcher({
|
|
100
|
+
polling: typeof poll === 'number',
|
|
101
|
+
interval: poll,
|
|
102
|
+
followSymlinks: preserveSymlinks,
|
|
103
|
+
ignored,
|
|
104
|
+
});
|
|
105
|
+
// Setup abort support
|
|
106
|
+
options.signal?.addEventListener('abort', () => void watcher?.close());
|
|
107
|
+
// Watch the entire project root if 'NG_BUILD_WATCH_ROOT' environment variable is set
|
|
108
|
+
if (environment_options_1.shouldWatchRoot) {
|
|
109
|
+
watcher.add(projectRoot);
|
|
110
|
+
}
|
|
111
|
+
watcher.add(packageWatchFiles
|
|
112
|
+
.map((file) => node_path_1.default.join(workspaceRoot, file))
|
|
113
|
+
.filter((file) => (0, node_fs_1.existsSync)(file)));
|
|
114
|
+
// Watch locations provided by the initial build result
|
|
115
|
+
watcher.add(result.watchFiles);
|
|
116
|
+
}
|
|
117
|
+
// Output the first build results after setting up the watcher to ensure that any code executed
|
|
118
|
+
// higher in the iterator call stack will trigger the watcher. This is particularly relevant for
|
|
119
|
+
// unit tests which execute the builder and modify the file system programmatically.
|
|
120
|
+
yield await writeAndEmitOutput(writeToFileSystem, result, outputOptions, writeToFileSystemFilter);
|
|
121
|
+
// Finish if watch mode is not enabled
|
|
122
|
+
if (!watcher) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
// Wait for changes and rebuild as needed
|
|
126
|
+
const currentWatchFiles = new Set(result.watchFiles);
|
|
127
|
+
try {
|
|
128
|
+
for await (const changes of watcher) {
|
|
129
|
+
if (options.signal?.aborted) {
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
if (clearScreen) {
|
|
133
|
+
// eslint-disable-next-line no-console
|
|
134
|
+
console.clear();
|
|
135
|
+
}
|
|
136
|
+
if (verbose) {
|
|
137
|
+
logger.info(changes.toDebugString());
|
|
138
|
+
}
|
|
139
|
+
result = await withProgress('Changes detected. Rebuilding...', () => action(result.createRebuildState(changes)));
|
|
140
|
+
// Log all diagnostic (error/warning/logs) messages
|
|
141
|
+
await (0, utils_1.logMessages)(logger, result, colors, jsonLogs);
|
|
142
|
+
// Update watched locations provided by the new build result.
|
|
143
|
+
// Keep watching all previous files if there are any errors; otherwise consider all
|
|
144
|
+
// files stale until confirmed present in the new result's watch files.
|
|
145
|
+
const staleWatchFiles = result.errors.length > 0 ? undefined : new Set(currentWatchFiles);
|
|
146
|
+
for (const watchFile of result.watchFiles) {
|
|
147
|
+
if (!currentWatchFiles.has(watchFile)) {
|
|
148
|
+
// Add new watch location
|
|
149
|
+
watcher.add(watchFile);
|
|
150
|
+
currentWatchFiles.add(watchFile);
|
|
151
|
+
}
|
|
152
|
+
// Present so remove from stale locations
|
|
153
|
+
staleWatchFiles?.delete(watchFile);
|
|
154
|
+
}
|
|
155
|
+
// Remove any stale locations if the build was successful
|
|
156
|
+
if (staleWatchFiles?.size) {
|
|
157
|
+
watcher.remove([...staleWatchFiles]);
|
|
158
|
+
}
|
|
159
|
+
yield await writeAndEmitOutput(writeToFileSystem, result, outputOptions, writeToFileSystemFilter);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
finally {
|
|
163
|
+
// Stop the watcher and cleanup incremental rebuild state
|
|
164
|
+
await Promise.allSettled([watcher.close(), result.dispose()]);
|
|
165
|
+
(0, sass_language_1.shutdownSassWorkerPool)();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.runEsBuildBuildAction = runEsBuildBuildAction;
|
|
169
|
+
async function writeAndEmitOutput(writeToFileSystem, { outputFiles, output, outputWithFiles, assetFiles }, outputOptions, writeToFileSystemFilter) {
|
|
170
|
+
if (writeToFileSystem) {
|
|
171
|
+
// Write output files
|
|
172
|
+
const outputFilesToWrite = writeToFileSystemFilter
|
|
173
|
+
? outputFiles.filter(writeToFileSystemFilter)
|
|
174
|
+
: outputFiles;
|
|
175
|
+
await (0, utils_1.writeResultFiles)(outputFilesToWrite, assetFiles, outputOptions);
|
|
176
|
+
return output;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
// Requires casting due to unneeded `JsonObject` requirement. Remove once fixed.
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
181
|
+
return outputWithFiles;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -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
|
+
import { BuilderContext } from '@angular-devkit/architect';
|
|
9
|
+
import { ExecutionResult, RebuildState } from '../../tools/esbuild/bundler-execution-result';
|
|
10
|
+
import { NormalizedApplicationBuildOptions } from './options';
|
|
11
|
+
export declare function executeBuild(options: NormalizedApplicationBuildOptions, context: BuilderContext, rebuildState?: RebuildState): Promise<ExecutionResult>;
|
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.executeBuild = void 0;
|
|
11
|
+
const source_file_cache_1 = require("../../tools/esbuild/angular/source-file-cache");
|
|
12
|
+
const budget_stats_1 = require("../../tools/esbuild/budget-stats");
|
|
13
|
+
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
|
14
|
+
const bundler_execution_result_1 = require("../../tools/esbuild/bundler-execution-result");
|
|
15
|
+
const commonjs_checker_1 = require("../../tools/esbuild/commonjs-checker");
|
|
16
|
+
const license_extractor_1 = require("../../tools/esbuild/license-extractor");
|
|
17
|
+
const utils_1 = require("../../tools/esbuild/utils");
|
|
18
|
+
const bundle_calculator_1 = require("../../utils/bundle-calculator");
|
|
19
|
+
const resolve_assets_1 = require("../../utils/resolve-assets");
|
|
20
|
+
const supported_browsers_1 = require("../../utils/supported-browsers");
|
|
21
|
+
const execute_post_bundle_1 = require("./execute-post-bundle");
|
|
22
|
+
const i18n_1 = require("./i18n");
|
|
23
|
+
const setup_bundling_1 = require("./setup-bundling");
|
|
24
|
+
async function executeBuild(options, context, rebuildState) {
|
|
25
|
+
const { projectRoot, workspaceRoot, i18nOptions, optimizationOptions, assets, cacheOptions, prerenderOptions, ssrOptions, verbose, colors, jsonLogs, } = options;
|
|
26
|
+
// TODO: Consider integrating into watch mode. Would require full rebuild on target changes.
|
|
27
|
+
const browsers = (0, supported_browsers_1.getSupportedBrowsers)(projectRoot, context.logger);
|
|
28
|
+
// Load active translations if inlining
|
|
29
|
+
// TODO: Integrate into watch mode and only load changed translations
|
|
30
|
+
if (i18nOptions.shouldInline) {
|
|
31
|
+
await (0, i18n_1.loadActiveTranslations)(context, i18nOptions);
|
|
32
|
+
}
|
|
33
|
+
// Reuse rebuild state or create new bundle contexts for code and global stylesheets
|
|
34
|
+
let bundlerContexts = rebuildState?.rebuildContexts;
|
|
35
|
+
const codeBundleCache = rebuildState?.codeBundleCache ??
|
|
36
|
+
new source_file_cache_1.SourceFileCache(cacheOptions.enabled ? cacheOptions.path : undefined);
|
|
37
|
+
if (bundlerContexts === undefined) {
|
|
38
|
+
bundlerContexts = (0, setup_bundling_1.setupBundlerContexts)(options, browsers, codeBundleCache);
|
|
39
|
+
}
|
|
40
|
+
const bundlingResult = await bundler_context_1.BundlerContext.bundleAll(bundlerContexts, rebuildState?.fileChanges.all);
|
|
41
|
+
const executionResult = new bundler_execution_result_1.ExecutionResult(bundlerContexts, codeBundleCache);
|
|
42
|
+
executionResult.addWarnings(bundlingResult.warnings);
|
|
43
|
+
// Return if the bundling has errors
|
|
44
|
+
if (bundlingResult.errors) {
|
|
45
|
+
executionResult.addErrors(bundlingResult.errors);
|
|
46
|
+
return executionResult;
|
|
47
|
+
}
|
|
48
|
+
// Analyze external imports if external options are enabled
|
|
49
|
+
if (options.externalPackages || bundlingResult.externalConfiguration) {
|
|
50
|
+
const { externalConfiguration, externalImports: { browser, server }, } = bundlingResult;
|
|
51
|
+
const implicitBrowser = browser ? [...browser] : [];
|
|
52
|
+
const implicitServer = server ? [...server] : [];
|
|
53
|
+
// TODO: Implement wildcard externalConfiguration filtering
|
|
54
|
+
executionResult.setExternalMetadata(externalConfiguration
|
|
55
|
+
? implicitBrowser.filter((value) => !externalConfiguration.includes(value))
|
|
56
|
+
: implicitBrowser, externalConfiguration
|
|
57
|
+
? implicitServer.filter((value) => !externalConfiguration.includes(value))
|
|
58
|
+
: implicitServer, externalConfiguration);
|
|
59
|
+
}
|
|
60
|
+
const { metafile, initialFiles, outputFiles } = bundlingResult;
|
|
61
|
+
executionResult.outputFiles.push(...outputFiles);
|
|
62
|
+
const changedFiles = rebuildState && executionResult.findChangedFiles(rebuildState.previousOutputHashes);
|
|
63
|
+
// Analyze files for bundle budget failures if present
|
|
64
|
+
let budgetFailures;
|
|
65
|
+
if (options.budgets) {
|
|
66
|
+
const compatStats = (0, budget_stats_1.generateBudgetStats)(metafile, initialFiles);
|
|
67
|
+
budgetFailures = [...(0, bundle_calculator_1.checkBudgets)(options.budgets, compatStats, true)];
|
|
68
|
+
for (const { message, severity } of budgetFailures) {
|
|
69
|
+
if (severity === 'error') {
|
|
70
|
+
executionResult.addError(message);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
executionResult.addWarning(message);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Calculate estimated transfer size if scripts are optimized
|
|
78
|
+
let estimatedTransferSizes;
|
|
79
|
+
if (optimizationOptions.scripts || optimizationOptions.styles.minify) {
|
|
80
|
+
estimatedTransferSizes = await (0, utils_1.calculateEstimatedTransferSizes)(executionResult.outputFiles);
|
|
81
|
+
}
|
|
82
|
+
// Check metafile for CommonJS module usage if optimizing scripts
|
|
83
|
+
if (optimizationOptions.scripts) {
|
|
84
|
+
const messages = (0, commonjs_checker_1.checkCommonJSModules)(metafile, options.allowedCommonJsDependencies);
|
|
85
|
+
executionResult.addWarnings(messages);
|
|
86
|
+
}
|
|
87
|
+
// Copy assets
|
|
88
|
+
if (assets) {
|
|
89
|
+
executionResult.addAssets(await (0, resolve_assets_1.resolveAssets)(assets, workspaceRoot));
|
|
90
|
+
}
|
|
91
|
+
// Extract and write licenses for used packages
|
|
92
|
+
if (options.extractLicenses) {
|
|
93
|
+
executionResult.addOutputFile('3rdpartylicenses.txt', await (0, license_extractor_1.extractLicenses)(metafile, workspaceRoot), bundler_context_1.BuildOutputFileType.Root);
|
|
94
|
+
}
|
|
95
|
+
// Perform i18n translation inlining if enabled
|
|
96
|
+
if (i18nOptions.shouldInline) {
|
|
97
|
+
const result = await (0, i18n_1.inlineI18n)(options, executionResult, initialFiles);
|
|
98
|
+
executionResult.addErrors(result.errors);
|
|
99
|
+
executionResult.addWarnings(result.warnings);
|
|
100
|
+
executionResult.addPrerenderedRoutes(result.prerenderedRoutes);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const result = await (0, execute_post_bundle_1.executePostBundleSteps)(options, executionResult.outputFiles, executionResult.assetFiles, initialFiles,
|
|
104
|
+
// Set lang attribute to the defined source locale if present
|
|
105
|
+
i18nOptions.hasDefinedSourceLocale ? i18nOptions.sourceLocale : undefined);
|
|
106
|
+
executionResult.addErrors(result.errors);
|
|
107
|
+
executionResult.addWarnings(result.warnings);
|
|
108
|
+
executionResult.addPrerenderedRoutes(result.prerenderedRoutes);
|
|
109
|
+
executionResult.outputFiles.push(...result.additionalOutputFiles);
|
|
110
|
+
executionResult.assetFiles.push(...result.additionalAssets);
|
|
111
|
+
}
|
|
112
|
+
if (prerenderOptions) {
|
|
113
|
+
const prerenderedRoutes = executionResult.prerenderedRoutes;
|
|
114
|
+
executionResult.addOutputFile('prerendered-routes.json', JSON.stringify({ routes: prerenderedRoutes }, null, 2), bundler_context_1.BuildOutputFileType.Root);
|
|
115
|
+
}
|
|
116
|
+
// Write metafile if stats option is enabled
|
|
117
|
+
if (options.stats) {
|
|
118
|
+
executionResult.addOutputFile('stats.json', JSON.stringify(metafile, null, 2), bundler_context_1.BuildOutputFileType.Root);
|
|
119
|
+
}
|
|
120
|
+
if (!jsonLogs) {
|
|
121
|
+
executionResult.addLog((0, utils_1.logBuildStats)(metafile, initialFiles, budgetFailures, colors, changedFiles, estimatedTransferSizes, !!ssrOptions, verbose));
|
|
122
|
+
}
|
|
123
|
+
return executionResult;
|
|
124
|
+
}
|
|
125
|
+
exports.executeBuild = executeBuild;
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
import { BuildOutputFile, InitialFileRecord } from '../../tools/esbuild/bundler-context';
|
|
9
|
+
import { BuildOutputAsset } from '../../tools/esbuild/bundler-execution-result';
|
|
10
|
+
import { NormalizedApplicationBuildOptions } from './options';
|
|
11
|
+
/**
|
|
12
|
+
* Run additional builds steps including SSG, AppShell, Index HTML file and Service worker generation.
|
|
13
|
+
* @param options The normalized application builder options used to create the build.
|
|
14
|
+
* @param outputFiles The output files of an executed build.
|
|
15
|
+
* @param assetFiles The assets of an executed build.
|
|
16
|
+
* @param initialFiles A map containing initial file information for the executed build.
|
|
17
|
+
* @param locale A language locale to insert in the index.html.
|
|
18
|
+
*/
|
|
19
|
+
export declare function executePostBundleSteps(options: NormalizedApplicationBuildOptions, outputFiles: BuildOutputFile[], assetFiles: BuildOutputAsset[], initialFiles: Map<string, InitialFileRecord>, locale: string | undefined): Promise<{
|
|
20
|
+
errors: string[];
|
|
21
|
+
warnings: string[];
|
|
22
|
+
additionalOutputFiles: BuildOutputFile[];
|
|
23
|
+
additionalAssets: BuildOutputAsset[];
|
|
24
|
+
prerenderedRoutes: string[];
|
|
25
|
+
}>;
|
|
@@ -0,0 +1,93 @@
|
|
|
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.executePostBundleSteps = void 0;
|
|
14
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
15
|
+
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
|
16
|
+
const index_html_generator_1 = require("../../tools/esbuild/index-html-generator");
|
|
17
|
+
const utils_1 = require("../../tools/esbuild/utils");
|
|
18
|
+
const environment_options_1 = require("../../utils/environment-options");
|
|
19
|
+
const prerender_1 = require("../../utils/server-rendering/prerender");
|
|
20
|
+
const service_worker_1 = require("../../utils/service-worker");
|
|
21
|
+
/**
|
|
22
|
+
* Run additional builds steps including SSG, AppShell, Index HTML file and Service worker generation.
|
|
23
|
+
* @param options The normalized application builder options used to create the build.
|
|
24
|
+
* @param outputFiles The output files of an executed build.
|
|
25
|
+
* @param assetFiles The assets of an executed build.
|
|
26
|
+
* @param initialFiles A map containing initial file information for the executed build.
|
|
27
|
+
* @param locale A language locale to insert in the index.html.
|
|
28
|
+
*/
|
|
29
|
+
async function executePostBundleSteps(options, outputFiles, assetFiles, initialFiles, locale) {
|
|
30
|
+
const additionalAssets = [];
|
|
31
|
+
const additionalOutputFiles = [];
|
|
32
|
+
const allErrors = [];
|
|
33
|
+
const allWarnings = [];
|
|
34
|
+
const prerenderedRoutes = [];
|
|
35
|
+
const { serviceWorker, indexHtmlOptions, optimizationOptions, sourcemapOptions, prerenderOptions, appShellOptions, workspaceRoot, verbose, } = options;
|
|
36
|
+
/**
|
|
37
|
+
* Index HTML content without CSS inlining to be used for server rendering (AppShell, SSG and SSR).
|
|
38
|
+
*
|
|
39
|
+
* NOTE: we don't perform critical CSS inlining as this will be done during server rendering.
|
|
40
|
+
*/
|
|
41
|
+
let ssrIndexContent;
|
|
42
|
+
// When using prerender/app-shell the index HTML file can be regenerated.
|
|
43
|
+
// Thus, we use a Map so that we do not generate 2 files with the same filename.
|
|
44
|
+
const additionalHtmlOutputFiles = new Map();
|
|
45
|
+
// Generate index HTML file
|
|
46
|
+
// If localization is enabled, index generation is handled in the inlining process.
|
|
47
|
+
if (indexHtmlOptions) {
|
|
48
|
+
const { csrContent, ssrContent, errors, warnings } = await (0, index_html_generator_1.generateIndexHtml)(initialFiles, outputFiles, options, locale);
|
|
49
|
+
allErrors.push(...errors);
|
|
50
|
+
allWarnings.push(...warnings);
|
|
51
|
+
additionalHtmlOutputFiles.set(indexHtmlOptions.output, (0, utils_1.createOutputFileFromText)(indexHtmlOptions.output, csrContent, bundler_context_1.BuildOutputFileType.Browser));
|
|
52
|
+
if (ssrContent) {
|
|
53
|
+
const serverIndexHtmlFilename = 'index.server.html';
|
|
54
|
+
additionalHtmlOutputFiles.set(serverIndexHtmlFilename, (0, utils_1.createOutputFileFromText)(serverIndexHtmlFilename, ssrContent, bundler_context_1.BuildOutputFileType.Server));
|
|
55
|
+
ssrIndexContent = ssrContent;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Pre-render (SSG) and App-shell
|
|
59
|
+
// If localization is enabled, prerendering is handled in the inlining process.
|
|
60
|
+
if (prerenderOptions || appShellOptions) {
|
|
61
|
+
(0, node_assert_1.default)(ssrIndexContent, 'The "index" option is required when using the "ssg" or "appShell" options.');
|
|
62
|
+
const { output, warnings, errors, prerenderedRoutes: generatedRoutes, } = await (0, prerender_1.prerenderPages)(workspaceRoot, appShellOptions, prerenderOptions, outputFiles, assetFiles, ssrIndexContent, sourcemapOptions.scripts, optimizationOptions.styles.inlineCritical, environment_options_1.maxWorkers, verbose);
|
|
63
|
+
allErrors.push(...errors);
|
|
64
|
+
allWarnings.push(...warnings);
|
|
65
|
+
prerenderedRoutes.push(...Array.from(generatedRoutes));
|
|
66
|
+
for (const [path, content] of Object.entries(output)) {
|
|
67
|
+
additionalHtmlOutputFiles.set(path, (0, utils_1.createOutputFileFromText)(path, content, bundler_context_1.BuildOutputFileType.Browser));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
additionalOutputFiles.push(...additionalHtmlOutputFiles.values());
|
|
71
|
+
// Augment the application with service worker support
|
|
72
|
+
// If localization is enabled, service worker is handled in the inlining process.
|
|
73
|
+
if (serviceWorker) {
|
|
74
|
+
try {
|
|
75
|
+
const serviceWorkerResult = await (0, service_worker_1.augmentAppWithServiceWorkerEsbuild)(workspaceRoot, serviceWorker, options.baseHref || '/', options.indexHtmlOptions?.output,
|
|
76
|
+
// Ensure additional files recently added are used
|
|
77
|
+
[...outputFiles, ...additionalOutputFiles], assetFiles);
|
|
78
|
+
additionalOutputFiles.push((0, utils_1.createOutputFileFromText)('ngsw.json', serviceWorkerResult.manifest, bundler_context_1.BuildOutputFileType.Browser));
|
|
79
|
+
additionalAssets.push(...serviceWorkerResult.assetFiles);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
allErrors.push(error instanceof Error ? error.message : `${error}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
errors: allErrors,
|
|
87
|
+
warnings: allWarnings,
|
|
88
|
+
additionalAssets,
|
|
89
|
+
prerenderedRoutes,
|
|
90
|
+
additionalOutputFiles,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
exports.executePostBundleSteps = executePostBundleSteps;
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
import { BuilderContext } from '@angular-devkit/architect';
|
|
9
|
+
import { InitialFileRecord } from '../../tools/esbuild/bundler-context';
|
|
10
|
+
import { ExecutionResult } from '../../tools/esbuild/bundler-execution-result';
|
|
11
|
+
import { NormalizedApplicationBuildOptions } from './options';
|
|
12
|
+
/**
|
|
13
|
+
* Inlines all active locales as specified by the application build options into all
|
|
14
|
+
* application JavaScript files created during the build.
|
|
15
|
+
* @param options The normalized application builder options used to create the build.
|
|
16
|
+
* @param executionResult The result of an executed build.
|
|
17
|
+
* @param initialFiles A map containing initial file information for the executed build.
|
|
18
|
+
*/
|
|
19
|
+
export declare function inlineI18n(options: NormalizedApplicationBuildOptions, executionResult: ExecutionResult, initialFiles: Map<string, InitialFileRecord>): Promise<{
|
|
20
|
+
errors: string[];
|
|
21
|
+
warnings: string[];
|
|
22
|
+
prerenderedRoutes: string[];
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Loads all active translations using the translation loaders from the `@angular/localize` package.
|
|
26
|
+
* @param context The architect builder context for the current build.
|
|
27
|
+
* @param i18n The normalized i18n options to use.
|
|
28
|
+
*/
|
|
29
|
+
export declare function loadActiveTranslations(context: BuilderContext, i18n: NormalizedApplicationBuildOptions['i18nOptions']): Promise<void>;
|