@angular-devkit/build-angular 15.0.0-next.0 → 15.0.0-next.2
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 +13 -15
- package/src/babel/presets/application.d.ts +1 -2
- package/src/babel/presets/application.js +1 -4
- package/src/babel/webpack-loader.js +8 -22
- package/src/builders/browser/index.d.ts +1 -1
- package/src/builders/browser/index.js +4 -16
- package/src/builders/browser/schema.json +2 -2
- package/src/builders/browser-esbuild/compiler-plugin.d.ts +1 -0
- package/src/builders/browser-esbuild/compiler-plugin.js +20 -17
- package/src/builders/browser-esbuild/experimental-warnings.js +0 -1
- package/src/builders/browser-esbuild/index.js +18 -5
- package/src/builders/browser-esbuild/schema.d.ts +2 -4
- package/src/builders/browser-esbuild/schema.json +13 -32
- package/src/builders/browser-esbuild/stylesheets.d.ts +1 -0
- package/src/builders/browser-esbuild/stylesheets.js +1 -0
- package/src/builders/extract-i18n/index.js +1 -1
- package/src/builders/karma/schema.json +2 -2
- package/src/builders/server/index.d.ts +1 -1
- package/src/builders/server/index.js +42 -28
- package/src/builders/server/platform-server-exports-loader.d.ts +13 -0
- package/src/builders/server/platform-server-exports-loader.js +24 -0
- package/src/builders/server/schema.d.ts +1 -10
- package/src/builders/server/schema.js +1 -6
- package/src/builders/server/schema.json +1 -9
- package/src/utils/build-options.d.ts +1 -2
- package/src/utils/esbuild-targets.d.ts +12 -0
- package/src/utils/esbuild-targets.js +39 -0
- package/src/utils/i18n-inlining.d.ts +1 -1
- package/src/utils/i18n-inlining.js +3 -4
- package/src/utils/normalize-builder-schema.d.ts +2 -2
- package/src/utils/normalize-builder-schema.js +2 -2
- package/src/utils/process-bundle.d.ts +0 -1
- package/src/utils/process-bundle.js +29 -57
- package/src/utils/supported-browsers.d.ts +2 -1
- package/src/utils/supported-browsers.js +18 -2
- package/src/utils/webpack-browser-config.d.ts +0 -2
- package/src/utils/webpack-browser-config.js +2 -8
- package/src/webpack/configs/common.js +19 -12
- package/src/webpack/configs/dev-server.js +1 -1
- package/src/webpack/configs/styles.js +6 -28
- package/src/webpack/plugins/any-component-style-budget-checker.js +1 -1
- package/src/webpack/plugins/css-optimizer-plugin.d.ts +0 -1
- package/src/webpack/plugins/css-optimizer-plugin.js +3 -26
- package/src/webpack/plugins/hmr/hmr-loader.d.ts +1 -1
- package/src/webpack/plugins/hmr/hmr-loader.js +2 -5
- package/src/webpack/plugins/javascript-optimizer-plugin.d.ts +4 -6
- package/src/webpack/plugins/javascript-optimizer-plugin.js +5 -14
- package/src/webpack/plugins/javascript-optimizer-worker.d.ts +3 -2
- package/src/webpack/plugins/javascript-optimizer-worker.js +21 -46
- package/src/webpack/plugins/typescript.js +14 -25
- package/src/webpack/utils/helpers.d.ts +0 -2
- package/src/webpack/utils/helpers.js +1 -17
- package/src/webpack/utils/stats.js +1 -1
package/package.json
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "15.0.0-next.
|
|
3
|
+
"version": "15.0.0-next.2",
|
|
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.2.0",
|
|
10
|
-
"@angular-devkit/architect": "0.1500.0-next.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1500.0-next.
|
|
12
|
-
"@angular-devkit/core": "15.0.0-next.
|
|
13
|
-
"@babel/core": "7.19.
|
|
10
|
+
"@angular-devkit/architect": "0.1500.0-next.2",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1500.0-next.2",
|
|
12
|
+
"@angular-devkit/core": "15.0.0-next.2",
|
|
13
|
+
"@babel/core": "7.19.1",
|
|
14
14
|
"@babel/generator": "7.19.0",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.18.6",
|
|
16
|
-
"@babel/plugin-proposal-async-generator-functions": "7.19.
|
|
16
|
+
"@babel/plugin-proposal-async-generator-functions": "7.19.1",
|
|
17
17
|
"@babel/plugin-transform-async-to-generator": "7.18.6",
|
|
18
|
-
"@babel/plugin-transform-runtime": "7.
|
|
19
|
-
"@babel/preset-env": "7.19.
|
|
18
|
+
"@babel/plugin-transform-runtime": "7.19.1",
|
|
19
|
+
"@babel/preset-env": "7.19.1",
|
|
20
20
|
"@babel/runtime": "7.19.0",
|
|
21
21
|
"@babel/template": "7.18.10",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.7",
|
|
23
|
-
"@ngtools/webpack": "15.0.0-next.
|
|
23
|
+
"@ngtools/webpack": "15.0.0-next.2",
|
|
24
24
|
"ansi-colors": "4.1.3",
|
|
25
|
+
"autoprefixer": "10.4.12",
|
|
25
26
|
"babel-loader": "8.2.5",
|
|
26
27
|
"babel-plugin-istanbul": "6.1.1",
|
|
27
28
|
"browserslist": "^4.9.1",
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
"copy-webpack-plugin": "11.0.0",
|
|
30
31
|
"critters": "0.0.16",
|
|
31
32
|
"css-loader": "6.7.1",
|
|
32
|
-
"esbuild-wasm": "0.15.
|
|
33
|
+
"esbuild-wasm": "0.15.8",
|
|
33
34
|
"glob": "8.0.3",
|
|
34
35
|
"https-proxy-agent": "5.0.1",
|
|
35
36
|
"inquirer": "8.2.4",
|
|
@@ -48,7 +49,6 @@
|
|
|
48
49
|
"postcss": "8.4.16",
|
|
49
50
|
"postcss-import": "15.0.0",
|
|
50
51
|
"postcss-loader": "7.0.1",
|
|
51
|
-
"postcss-preset-env": "7.8.1",
|
|
52
52
|
"regenerator-runtime": "0.13.9",
|
|
53
53
|
"resolve-url-loader": "5.0.0",
|
|
54
54
|
"rxjs": "6.6.7",
|
|
@@ -57,20 +57,18 @@
|
|
|
57
57
|
"semver": "7.3.7",
|
|
58
58
|
"source-map-loader": "4.0.0",
|
|
59
59
|
"source-map-support": "0.5.21",
|
|
60
|
-
"stylus": "0.59.0",
|
|
61
|
-
"stylus-loader": "7.0.0",
|
|
62
60
|
"terser": "5.15.0",
|
|
63
61
|
"text-table": "0.2.0",
|
|
64
62
|
"tree-kill": "1.2.2",
|
|
65
63
|
"tslib": "2.4.0",
|
|
66
64
|
"webpack": "5.74.0",
|
|
67
65
|
"webpack-dev-middleware": "5.3.3",
|
|
68
|
-
"webpack-dev-server": "4.11.
|
|
66
|
+
"webpack-dev-server": "4.11.1",
|
|
69
67
|
"webpack-merge": "5.8.0",
|
|
70
68
|
"webpack-subresource-integrity": "5.1.0"
|
|
71
69
|
},
|
|
72
70
|
"optionalDependencies": {
|
|
73
|
-
"esbuild": "0.15.
|
|
71
|
+
"esbuild": "0.15.8"
|
|
74
72
|
},
|
|
75
73
|
"peerDependencies": {
|
|
76
74
|
"@angular/compiler-cli": "^15.0.0-next",
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import type { ɵParsedTranslation } from '@angular/localize';
|
|
9
|
-
import type { makeEs2015TranslatePlugin,
|
|
9
|
+
import type { makeEs2015TranslatePlugin, makeLocalePlugin } from '@angular/localize/tools';
|
|
10
10
|
export declare type DiagnosticReporter = (type: 'error' | 'warning' | 'info', message: string) => void;
|
|
11
11
|
/**
|
|
12
12
|
* An interface representing the factory functions for the `@angular/localize` translation Babel plugins.
|
|
@@ -16,7 +16,6 @@ export declare type DiagnosticReporter = (type: 'error' | 'warning' | 'info', me
|
|
|
16
16
|
*/
|
|
17
17
|
export interface I18nPluginCreators {
|
|
18
18
|
makeEs2015TranslatePlugin: typeof makeEs2015TranslatePlugin;
|
|
19
|
-
makeEs5TranslatePlugin: typeof makeEs5TranslatePlugin;
|
|
20
19
|
makeLocalePlugin: typeof makeLocalePlugin;
|
|
21
20
|
}
|
|
22
21
|
export interface ApplicationPresetOptions {
|
|
@@ -67,14 +67,11 @@ function createI18nDiagnostics(reporter) {
|
|
|
67
67
|
function createI18nPlugins(locale, translation, missingTranslationBehavior, diagnosticReporter, pluginCreators) {
|
|
68
68
|
const diagnostics = createI18nDiagnostics(diagnosticReporter);
|
|
69
69
|
const plugins = [];
|
|
70
|
-
const {
|
|
70
|
+
const { makeEs2015TranslatePlugin, makeLocalePlugin } = pluginCreators;
|
|
71
71
|
if (translation) {
|
|
72
72
|
plugins.push(makeEs2015TranslatePlugin(diagnostics, translation, {
|
|
73
73
|
missingTranslation: missingTranslationBehavior,
|
|
74
74
|
}));
|
|
75
|
-
plugins.push(makeEs5TranslatePlugin(diagnostics, translation, {
|
|
76
|
-
missingTranslation: missingTranslationBehavior,
|
|
77
|
-
}));
|
|
78
75
|
}
|
|
79
76
|
plugins.push(makeLocalePlugin(locale));
|
|
80
77
|
return plugins;
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.requiresLinking = void 0;
|
|
11
11
|
const babel_loader_1 = require("babel-loader");
|
|
12
|
-
const typescript_1 = require("typescript");
|
|
13
12
|
const load_esm_1 = require("../utils/load-esm");
|
|
14
13
|
const package_version_1 = require("../utils/package-version");
|
|
15
14
|
/**
|
|
@@ -53,7 +52,7 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
53
52
|
return {
|
|
54
53
|
async customOptions(options, { source, map }) {
|
|
55
54
|
var _a, _b, _c;
|
|
56
|
-
const { i18n,
|
|
55
|
+
const { i18n, aot, optimize, instrumentCode, supportedBrowsers, ...rawOptions } = options;
|
|
57
56
|
// Must process file if plugins are added
|
|
58
57
|
let shouldProcess = Array.isArray(rawOptions.plugins) && rawOptions.plugins.length > 0;
|
|
59
58
|
const customOptions = {
|
|
@@ -78,31 +77,18 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
78
77
|
shouldProcess = true;
|
|
79
78
|
}
|
|
80
79
|
// Analyze for ES target processing
|
|
81
|
-
|
|
82
|
-
const isJsFile = /\.[cm]?js$/.test(this.resourcePath);
|
|
83
|
-
// The below should be dropped when we no longer support ES5 TypeScript output.
|
|
84
|
-
if (esTarget === typescript_1.ScriptTarget.ES5) {
|
|
85
|
-
// This is needed because when target is ES5 we change the TypeScript target to ES2015
|
|
86
|
-
// because it simplifies build-optimization passes.
|
|
87
|
-
// @see https://github.com/angular/angular-cli/blob/22af6520834171d01413d4c7e4a9f13fb752252e/packages/angular_devkit/build_angular/src/webpack/plugins/typescript.ts#L51-L56
|
|
88
|
-
customOptions.forcePresetEnv = true;
|
|
89
|
-
// Comparable behavior to tsconfig target of ES5
|
|
90
|
-
customOptions.supportedBrowsers = ['IE 9'];
|
|
91
|
-
}
|
|
92
|
-
else if (isJsFile && ((_a = customOptions.supportedBrowsers) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
80
|
+
if ((_a = customOptions.supportedBrowsers) === null || _a === void 0 ? void 0 : _a.length) {
|
|
93
81
|
// Applications code ES version can be controlled using TypeScript's `target` option.
|
|
94
82
|
// However, this doesn't effect libraries and hence we use preset-env to downlevel ES fetaures
|
|
95
83
|
// based on the supported browsers in browserlist.
|
|
96
84
|
customOptions.forcePresetEnv = true;
|
|
97
85
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
!/[\\/][_f]?esm2015[\\/]/.test(this.resourcePath) && source.includes('async');
|
|
105
|
-
}
|
|
86
|
+
// Application code (TS files) will only contain native async if target is ES2017+.
|
|
87
|
+
// However, third-party libraries can regardless of the target option.
|
|
88
|
+
// APF packages with code in [f]esm2015 directories is downlevelled to ES2015 and
|
|
89
|
+
// will not have native async.
|
|
90
|
+
customOptions.forceAsyncTransformation =
|
|
91
|
+
!/[\\/][_f]?esm2015[\\/]/.test(this.resourcePath) && source.includes('async');
|
|
106
92
|
shouldProcess || (shouldProcess = customOptions.forceAsyncTransformation || customOptions.forcePresetEnv || false);
|
|
107
93
|
// Analyze for i18n inlining
|
|
108
94
|
if (i18n &&
|
|
@@ -44,5 +44,5 @@ export declare function buildWebpackBrowser(options: BrowserBuilderSchema, conte
|
|
|
44
44
|
logging?: WebpackLoggingCallback;
|
|
45
45
|
indexHtml?: IndexHtmlTransform;
|
|
46
46
|
}): Observable<BrowserBuilderOutput>;
|
|
47
|
-
declare const _default: import("@angular-devkit/architect/src/internal").Builder<BrowserBuilderSchema & import("
|
|
47
|
+
declare const _default: import("@angular-devkit/architect/src/internal").Builder<BrowserBuilderSchema & import("../../../../core/src").JsonObject>;
|
|
48
48
|
export default _default;
|
|
@@ -37,7 +37,6 @@ const fs = __importStar(require("fs"));
|
|
|
37
37
|
const path = __importStar(require("path"));
|
|
38
38
|
const rxjs_1 = require("rxjs");
|
|
39
39
|
const operators_1 = require("rxjs/operators");
|
|
40
|
-
const typescript_1 = require("typescript");
|
|
41
40
|
const utils_1 = require("../../utils");
|
|
42
41
|
const bundle_calculator_1 = require("../../utils/bundle-calculator");
|
|
43
42
|
const color_1 = require("../../utils/color");
|
|
@@ -51,7 +50,6 @@ const package_chunk_sort_1 = require("../../utils/package-chunk-sort");
|
|
|
51
50
|
const purge_cache_1 = require("../../utils/purge-cache");
|
|
52
51
|
const service_worker_1 = require("../../utils/service-worker");
|
|
53
52
|
const spinner_1 = require("../../utils/spinner");
|
|
54
|
-
const supported_browsers_1 = require("../../utils/supported-browsers");
|
|
55
53
|
const version_1 = require("../../utils/version");
|
|
56
54
|
const webpack_browser_config_1 = require("../../utils/webpack-browser-config");
|
|
57
55
|
const configs_1 = require("../../webpack/configs");
|
|
@@ -68,7 +66,7 @@ async function initialize(options, context, webpackConfigurationTransform) {
|
|
|
68
66
|
const originalOutputPath = options.outputPath;
|
|
69
67
|
// Assets are processed directly by the builder except when watching
|
|
70
68
|
const adjustedOptions = options.watch ? options : { ...options, assets: [] };
|
|
71
|
-
const { config, projectRoot, projectSourceRoot, i18n
|
|
69
|
+
const { config, projectRoot, projectSourceRoot, i18n } = await (0, webpack_browser_config_1.generateI18nBrowserWebpackConfigFromContext)(adjustedOptions, context, (wco) => [
|
|
72
70
|
(0, configs_1.getCommonConfig)(wco),
|
|
73
71
|
(0, configs_1.getStylesConfig)(wco),
|
|
74
72
|
(0, configs_1.getAnalyticsConfig)(wco, context),
|
|
@@ -88,7 +86,7 @@ async function initialize(options, context, webpackConfigurationTransform) {
|
|
|
88
86
|
if (options.deleteOutputPath) {
|
|
89
87
|
(0, utils_1.deleteOutputDir)(context.workspaceRoot, originalOutputPath);
|
|
90
88
|
}
|
|
91
|
-
return { config: transformedConfig || config, projectRoot, projectSourceRoot, i18n
|
|
89
|
+
return { config: transformedConfig || config, projectRoot, projectSourceRoot, i18n };
|
|
92
90
|
}
|
|
93
91
|
/**
|
|
94
92
|
* @experimental Direct usage of this function is considered experimental.
|
|
@@ -111,8 +109,6 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
111
109
|
await (0, purge_cache_1.purgeStaleBuildCache)(context);
|
|
112
110
|
// Initialize builder
|
|
113
111
|
const initialization = await initialize(options, context, transforms.webpackConfiguration);
|
|
114
|
-
// Check and warn about IE browser support
|
|
115
|
-
checkInternetExplorerSupport(initialization.projectRoot, context.logger);
|
|
116
112
|
// Add index file to watched files.
|
|
117
113
|
if (options.watch) {
|
|
118
114
|
const indexInputFile = path.join(context.workspaceRoot, (0, webpack_browser_config_1.getIndexInputFile)(options.index));
|
|
@@ -131,7 +127,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
131
127
|
};
|
|
132
128
|
}), (0, operators_1.switchMap)(
|
|
133
129
|
// eslint-disable-next-line max-lines-per-function
|
|
134
|
-
({ config, projectRoot, projectSourceRoot, i18n,
|
|
130
|
+
({ config, projectRoot, projectSourceRoot, i18n, cacheOptions }) => {
|
|
135
131
|
const normalizedOptimization = (0, utils_1.normalizeOptimization)(options.optimization);
|
|
136
132
|
return (0, build_webpack_1.runWebpack)(config, context, {
|
|
137
133
|
webpackFactory: require('webpack'),
|
|
@@ -174,7 +170,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
174
170
|
outputPaths = (0, output_paths_1.ensureOutputPaths)(baseOutputPath, i18n);
|
|
175
171
|
const scriptsEntryPointName = (0, helpers_1.normalizeExtraEntryPoints)(options.scripts || [], 'scripts').map((x) => x.bundleName);
|
|
176
172
|
if (i18n.shouldInline) {
|
|
177
|
-
const success = await (0, i18n_inlining_1.i18nInlineEmittedFiles)(context, emittedFiles, i18n, baseOutputPath, Array.from(outputPaths.values()), scriptsEntryPointName, webpackOutputPath,
|
|
173
|
+
const success = await (0, i18n_inlining_1.i18nInlineEmittedFiles)(context, emittedFiles, i18n, baseOutputPath, Array.from(outputPaths.values()), scriptsEntryPointName, webpackOutputPath, options.i18nMissingTranslation);
|
|
178
174
|
if (!success) {
|
|
179
175
|
return { success: false };
|
|
180
176
|
}
|
|
@@ -330,12 +326,4 @@ function mapEmittedFilesToFileInfo(files = []) {
|
|
|
330
326
|
}
|
|
331
327
|
return filteredFiles;
|
|
332
328
|
}
|
|
333
|
-
function checkInternetExplorerSupport(projectRoot, logger) {
|
|
334
|
-
const supportedBrowsers = (0, supported_browsers_1.getSupportedBrowsers)(projectRoot);
|
|
335
|
-
if (supportedBrowsers.some((b) => b === 'ie 9' || b === 'ie 10' || b === 'ie 11')) {
|
|
336
|
-
logger.warn(`Warning: Support was requested for Internet Explorer in the project's browserslist configuration. ` +
|
|
337
|
-
'Internet Explorer is no longer officially supported.' +
|
|
338
|
-
'\nFor more information, see https://angular.io/guide/browser-support');
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
329
|
exports.default = (0, architect_1.createBuilder)(buildWebpackBrowser);
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"input": {
|
|
73
73
|
"type": "string",
|
|
74
74
|
"description": "The file to include.",
|
|
75
|
-
"pattern": "\\.(?:css|scss|sass|less
|
|
75
|
+
"pattern": "\\.(?:css|scss|sass|less)$"
|
|
76
76
|
},
|
|
77
77
|
"bundleName": {
|
|
78
78
|
"type": "string",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
{
|
|
92
92
|
"type": "string",
|
|
93
93
|
"description": "The file to include.",
|
|
94
|
-
"pattern": "\\.(?:css|scss|sass|less
|
|
94
|
+
"pattern": "\\.(?:css|scss|sass|less)$"
|
|
95
95
|
}
|
|
96
96
|
]
|
|
97
97
|
}
|
|
@@ -113,15 +113,15 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
113
113
|
name: 'angular-compiler',
|
|
114
114
|
// eslint-disable-next-line max-lines-per-function
|
|
115
115
|
async setup(build) {
|
|
116
|
-
var _a;
|
|
117
|
-
var
|
|
116
|
+
var _a, _b;
|
|
117
|
+
var _c;
|
|
118
118
|
// This uses a wrapped dynamic import to load `@angular/compiler-cli` which is ESM.
|
|
119
119
|
// Once TypeScript provides support for retaining dynamic imports this workaround can be dropped.
|
|
120
120
|
const compilerCli = await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli');
|
|
121
121
|
// Temporary deep import for transformer support
|
|
122
122
|
const { mergeTransformers, replaceBootstrap, } = require('@ngtools/webpack/src/ivy/transformation');
|
|
123
123
|
// Setup defines based on the values provided by the Angular compiler-cli
|
|
124
|
-
(_a = (
|
|
124
|
+
(_a = (_c = build.initialOptions).define) !== null && _a !== void 0 ? _a : (_c.define = {});
|
|
125
125
|
for (const [key, value] of Object.entries(compilerCli.GLOBAL_DEFS_FOR_TERSER_WITH_AOT)) {
|
|
126
126
|
if (key in build.initialOptions.define) {
|
|
127
127
|
// Skip keys that have been manually provided
|
|
@@ -148,16 +148,13 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
148
148
|
annotationsAs: 'decorators',
|
|
149
149
|
enableResourceInlining: false,
|
|
150
150
|
});
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
build.initialOptions.target = typescript_1.default.ScriptTarget[compilerOptions.target].toLowerCase();
|
|
151
|
+
if (compilerOptions.target === undefined || compilerOptions.target < typescript_1.default.ScriptTarget.ES2022) {
|
|
152
|
+
// If 'useDefineForClassFields' is already defined in the users project leave the value as is.
|
|
153
|
+
// Otherwise fallback to false due to https://github.com/microsoft/TypeScript/issues/45995
|
|
154
|
+
// which breaks the deprecated `@Effects` NGRX decorator and potentially other existing code as well.
|
|
155
|
+
compilerOptions.target = typescript_1.default.ScriptTarget.ES2022;
|
|
156
|
+
(_b = compilerOptions.useDefineForClassFields) !== null && _b !== void 0 ? _b : (compilerOptions.useDefineForClassFields = false);
|
|
157
|
+
// TODO: show warning about this override when we have access to the logger.
|
|
161
158
|
}
|
|
162
159
|
// The file emitter created during `onStart` that will be used during the build in `onLoad` callbacks for TS files
|
|
163
160
|
let fileEmitter;
|
|
@@ -204,6 +201,12 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
204
201
|
stylesheetResourceFiles.push(...resourceFiles);
|
|
205
202
|
return { content: contents };
|
|
206
203
|
};
|
|
204
|
+
// Augment TypeScript Host for file replacements option
|
|
205
|
+
if (pluginOptions.fileReplacements) {
|
|
206
|
+
// Temporary deep import for file replacements support
|
|
207
|
+
const { augmentHostWithReplacements } = require('@ngtools/webpack/src/ivy/host');
|
|
208
|
+
augmentHostWithReplacements(host, pluginOptions.fileReplacements);
|
|
209
|
+
}
|
|
207
210
|
// Create the Angular specific program that contains the Angular compiler
|
|
208
211
|
const angularProgram = new compilerCli.NgtscProgram(rootNames, compilerOptions, host);
|
|
209
212
|
const angularCompiler = angularProgram.compiler;
|
|
@@ -244,9 +247,9 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
244
247
|
return result;
|
|
245
248
|
});
|
|
246
249
|
build.onLoad({ filter: compilerOptions.allowJs ? /\.[cm]?[jt]sx?$/ : /\.[cm]?tsx?$/ }, async (args) => {
|
|
247
|
-
var _a, _b;
|
|
250
|
+
var _a, _b, _c, _d;
|
|
248
251
|
assert.ok(fileEmitter, 'Invalid plugin execution order');
|
|
249
|
-
const typescriptResult = await fileEmitter(args.path);
|
|
252
|
+
const typescriptResult = await fileEmitter((_b = (_a = pluginOptions.fileReplacements) === null || _a === void 0 ? void 0 : _a[args.path]) !== null && _b !== void 0 ? _b : args.path);
|
|
250
253
|
if (!typescriptResult) {
|
|
251
254
|
// No TS result indicates the file is not part of the TypeScript program.
|
|
252
255
|
// If allowJs is enabled and the file is JS then defer to the next load hook.
|
|
@@ -268,7 +271,7 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
268
271
|
],
|
|
269
272
|
};
|
|
270
273
|
}
|
|
271
|
-
const data = (
|
|
274
|
+
const data = (_c = typescriptResult.content) !== null && _c !== void 0 ? _c : '';
|
|
272
275
|
const forceAsyncTransformation = /async\s+function\s*\*/.test(data);
|
|
273
276
|
const useInputSourcemap = pluginOptions.sourcemap &&
|
|
274
277
|
(!!pluginOptions.thirdPartySourcemaps || !/[\\/]node_modules[\\/]/.test(args.path));
|
|
@@ -302,7 +305,7 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
302
305
|
],
|
|
303
306
|
});
|
|
304
307
|
return {
|
|
305
|
-
contents: (
|
|
308
|
+
contents: (_d = babelResult === null || babelResult === void 0 ? void 0 : babelResult.code) !== null && _d !== void 0 ? _d : '',
|
|
306
309
|
loader: 'js',
|
|
307
310
|
};
|
|
308
311
|
});
|
|
@@ -38,9 +38,11 @@ const path = __importStar(require("path"));
|
|
|
38
38
|
const utils_1 = require("../../utils");
|
|
39
39
|
const copy_assets_1 = require("../../utils/copy-assets");
|
|
40
40
|
const error_1 = require("../../utils/error");
|
|
41
|
+
const esbuild_targets_1 = require("../../utils/esbuild-targets");
|
|
41
42
|
const index_html_generator_1 = require("../../utils/index-file/index-html-generator");
|
|
42
43
|
const package_chunk_sort_1 = require("../../utils/package-chunk-sort");
|
|
43
44
|
const service_worker_1 = require("../../utils/service-worker");
|
|
45
|
+
const supported_browsers_1 = require("../../utils/supported-browsers");
|
|
44
46
|
const webpack_browser_config_1 = require("../../utils/webpack-browser-config");
|
|
45
47
|
const configs_1 = require("../../webpack/configs");
|
|
46
48
|
const compiler_plugin_1 = require("./compiler-plugin");
|
|
@@ -86,11 +88,12 @@ async function buildEsbuildBrowser(options, context) {
|
|
|
86
88
|
context.logger.error('Unable to create output directory: ' + e.message);
|
|
87
89
|
return { success: false };
|
|
88
90
|
}
|
|
91
|
+
const target = (0, esbuild_targets_1.transformSupportedBrowsersToTargets)((0, supported_browsers_1.getSupportedBrowsers)(projectRoot, context.logger));
|
|
89
92
|
const [codeResults, styleResults] = await Promise.all([
|
|
90
93
|
// Execute esbuild to bundle the application code
|
|
91
|
-
bundleCode(workspaceRoot, entryPoints, outputNames, options, optimizationOptions, sourcemapOptions, tsconfig),
|
|
94
|
+
bundleCode(workspaceRoot, entryPoints, outputNames, options, optimizationOptions, sourcemapOptions, tsconfig, target),
|
|
92
95
|
// Execute esbuild to bundle the global stylesheets
|
|
93
|
-
bundleGlobalStylesheets(workspaceRoot, outputNames, options, optimizationOptions, sourcemapOptions),
|
|
96
|
+
bundleGlobalStylesheets(workspaceRoot, outputNames, options, optimizationOptions, sourcemapOptions, target),
|
|
94
97
|
]);
|
|
95
98
|
// Log all warnings and errors generated during bundling
|
|
96
99
|
await (0, esbuild_1.logMessages)(context, {
|
|
@@ -195,8 +198,15 @@ function createOutputFileFromText(path, text) {
|
|
|
195
198
|
},
|
|
196
199
|
};
|
|
197
200
|
}
|
|
198
|
-
async function bundleCode(workspaceRoot, entryPoints, outputNames, options, optimizationOptions, sourcemapOptions, tsconfig) {
|
|
201
|
+
async function bundleCode(workspaceRoot, entryPoints, outputNames, options, optimizationOptions, sourcemapOptions, tsconfig, target) {
|
|
199
202
|
var _a;
|
|
203
|
+
let fileReplacements;
|
|
204
|
+
if (options.fileReplacements) {
|
|
205
|
+
for (const replacement of options.fileReplacements) {
|
|
206
|
+
fileReplacements !== null && fileReplacements !== void 0 ? fileReplacements : (fileReplacements = {});
|
|
207
|
+
fileReplacements[path.join(workspaceRoot, replacement.replace)] = path.join(workspaceRoot, replacement.with);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
200
210
|
return (0, esbuild_1.bundle)({
|
|
201
211
|
absWorkingDir: workspaceRoot,
|
|
202
212
|
bundle: true,
|
|
@@ -204,7 +214,7 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
|
|
|
204
214
|
entryPoints,
|
|
205
215
|
entryNames: outputNames.bundles,
|
|
206
216
|
assetNames: outputNames.media,
|
|
207
|
-
target
|
|
217
|
+
target,
|
|
208
218
|
supported: {
|
|
209
219
|
// Native async/await is not supported with Zone.js. Disabling support here will cause
|
|
210
220
|
// esbuild to downlevel async/await and for await...of to a Zone.js supported form. However, esbuild
|
|
@@ -236,6 +246,7 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
|
|
|
236
246
|
thirdPartySourcemaps: sourcemapOptions.vendor,
|
|
237
247
|
tsconfig,
|
|
238
248
|
advancedOptimizations: options.buildOptimizer,
|
|
249
|
+
fileReplacements,
|
|
239
250
|
},
|
|
240
251
|
// Component stylesheet options
|
|
241
252
|
{
|
|
@@ -249,6 +260,7 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
|
|
|
249
260
|
outputNames,
|
|
250
261
|
includePaths: (_a = options.stylePreprocessorOptions) === null || _a === void 0 ? void 0 : _a.includePaths,
|
|
251
262
|
externalDependencies: options.externalDependencies,
|
|
263
|
+
target,
|
|
252
264
|
}),
|
|
253
265
|
],
|
|
254
266
|
define: {
|
|
@@ -257,7 +269,7 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
|
|
|
257
269
|
},
|
|
258
270
|
});
|
|
259
271
|
}
|
|
260
|
-
async function bundleGlobalStylesheets(workspaceRoot, outputNames, options, optimizationOptions, sourcemapOptions) {
|
|
272
|
+
async function bundleGlobalStylesheets(workspaceRoot, outputNames, options, optimizationOptions, sourcemapOptions, target) {
|
|
261
273
|
var _a;
|
|
262
274
|
const outputFiles = [];
|
|
263
275
|
const initialFiles = [];
|
|
@@ -281,6 +293,7 @@ async function bundleGlobalStylesheets(workspaceRoot, outputNames, options, opti
|
|
|
281
293
|
includePaths: (_a = options.stylePreprocessorOptions) === null || _a === void 0 ? void 0 : _a.includePaths,
|
|
282
294
|
preserveSymlinks: options.preserveSymlinks,
|
|
283
295
|
externalDependencies: options.externalDependencies,
|
|
296
|
+
target,
|
|
284
297
|
});
|
|
285
298
|
errors.push(...sheetResult.errors);
|
|
286
299
|
warnings.push(...sheetResult.warnings);
|
|
@@ -262,10 +262,8 @@ export declare enum CrossOrigin {
|
|
|
262
262
|
UseCredentials = "use-credentials"
|
|
263
263
|
}
|
|
264
264
|
export interface FileReplacement {
|
|
265
|
-
replace
|
|
266
|
-
|
|
267
|
-
src?: string;
|
|
268
|
-
with?: string;
|
|
265
|
+
replace: string;
|
|
266
|
+
with: string;
|
|
269
267
|
}
|
|
270
268
|
/**
|
|
271
269
|
* How to handle duplicate translations for i18n.
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"input": {
|
|
73
73
|
"type": "string",
|
|
74
74
|
"description": "The file to include.",
|
|
75
|
-
"pattern": "\\.(?:css|scss|sass|less
|
|
75
|
+
"pattern": "\\.(?:css|scss|sass|less)$"
|
|
76
76
|
},
|
|
77
77
|
"bundleName": {
|
|
78
78
|
"type": "string",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
{
|
|
92
92
|
"type": "string",
|
|
93
93
|
"description": "The file to include.",
|
|
94
|
-
"pattern": "\\.(?:css|scss|sass|less
|
|
94
|
+
"pattern": "\\.(?:css|scss|sass|less)$"
|
|
95
95
|
}
|
|
96
96
|
]
|
|
97
97
|
}
|
|
@@ -461,38 +461,19 @@
|
|
|
461
461
|
]
|
|
462
462
|
},
|
|
463
463
|
"fileReplacement": {
|
|
464
|
-
"
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
"
|
|
468
|
-
|
|
469
|
-
"type": "string",
|
|
470
|
-
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
471
|
-
},
|
|
472
|
-
"replaceWith": {
|
|
473
|
-
"type": "string",
|
|
474
|
-
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
475
|
-
}
|
|
476
|
-
},
|
|
477
|
-
"additionalProperties": false,
|
|
478
|
-
"required": ["src", "replaceWith"]
|
|
464
|
+
"type": "object",
|
|
465
|
+
"properties": {
|
|
466
|
+
"replace": {
|
|
467
|
+
"type": "string",
|
|
468
|
+
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
479
469
|
},
|
|
480
|
-
{
|
|
481
|
-
"type": "
|
|
482
|
-
"
|
|
483
|
-
"replace": {
|
|
484
|
-
"type": "string",
|
|
485
|
-
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
486
|
-
},
|
|
487
|
-
"with": {
|
|
488
|
-
"type": "string",
|
|
489
|
-
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
490
|
-
}
|
|
491
|
-
},
|
|
492
|
-
"additionalProperties": false,
|
|
493
|
-
"required": ["replace", "with"]
|
|
470
|
+
"with": {
|
|
471
|
+
"type": "string",
|
|
472
|
+
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
494
473
|
}
|
|
495
|
-
|
|
474
|
+
},
|
|
475
|
+
"additionalProperties": false,
|
|
476
|
+
"required": ["replace", "with"]
|
|
496
477
|
},
|
|
497
478
|
"budget": {
|
|
498
479
|
"type": "object",
|
|
@@ -53,6 +53,7 @@ async function bundleStylesheet(entry, options) {
|
|
|
53
53
|
outdir: options.workspaceRoot,
|
|
54
54
|
write: false,
|
|
55
55
|
platform: 'browser',
|
|
56
|
+
target: options.target,
|
|
56
57
|
preserveSymlinks: options.preserveSymlinks,
|
|
57
58
|
external: options.externalDependencies,
|
|
58
59
|
conditions: ['style', 'sass'],
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"input": {
|
|
77
77
|
"type": "string",
|
|
78
78
|
"description": "The file to include.",
|
|
79
|
-
"pattern": "\\.(?:css|scss|sass|less
|
|
79
|
+
"pattern": "\\.(?:css|scss|sass|less)$"
|
|
80
80
|
},
|
|
81
81
|
"bundleName": {
|
|
82
82
|
"type": "string",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
{
|
|
96
96
|
"type": "string",
|
|
97
97
|
"description": "The file to include.",
|
|
98
|
-
"pattern": "\\.(?:css|scss|sass|less
|
|
98
|
+
"pattern": "\\.(?:css|scss|sass|less)$"
|
|
99
99
|
}
|
|
100
100
|
]
|
|
101
101
|
}
|
|
@@ -35,5 +35,5 @@ export { ServerBuilderOptions };
|
|
|
35
35
|
export declare function execute(options: ServerBuilderOptions, context: BuilderContext, transforms?: {
|
|
36
36
|
webpackConfiguration?: ExecutionTransformer<webpack.Configuration>;
|
|
37
37
|
}): Observable<ServerBuilderOutput>;
|
|
38
|
-
declare const _default: import("@angular-devkit/architect/src/internal").Builder<ServerBuilderOptions & import("
|
|
38
|
+
declare const _default: import("@angular-devkit/architect/src/internal").Builder<ServerBuilderOptions & import("../../../../core/src").JsonObject>;
|
|
39
39
|
export default _default;
|