@angular-devkit/build-angular 13.0.0-next.6 → 13.0.0-next.7
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 +14 -14
- package/src/babel/plugins/adjust-static-class-members.js +2 -2
- package/src/babel/plugins/adjust-typescript-enums.js +8 -2
- package/src/babel/plugins/pure-toplevel-functions.js +2 -2
- package/src/babel/presets/application.d.ts +14 -0
- package/src/babel/presets/application.js +42 -36
- package/src/babel/webpack-loader.js +50 -5
- package/src/builders/app-shell/index.js +9 -9
- package/src/builders/browser/index.js +42 -52
- package/src/builders/dev-server/index.js +23 -23
- package/src/builders/extract-i18n/index.js +33 -21
- package/src/builders/extract-i18n/ivy-extract-loader.js +34 -8
- package/src/builders/karma/find-tests.js +5 -5
- package/src/builders/karma/index.js +14 -14
- package/src/builders/ng-packagr/index.js +4 -4
- package/src/builders/protractor/index.js +4 -4
- package/src/builders/server/index.js +16 -16
- package/src/sass/worker.js +2 -2
- package/src/utils/build-browser-features.js +2 -2
- package/src/utils/bundle-calculator.js +4 -4
- package/src/utils/cache-path.js +2 -2
- package/src/utils/check-port.js +1 -1
- package/src/utils/copy-assets.js +1 -1
- package/src/utils/delete-output-dir.js +1 -1
- package/src/utils/i18n-inlining.js +1 -1
- package/src/utils/i18n-options.js +26 -50
- package/src/utils/index-file/augment-index-html.js +2 -2
- package/src/utils/index-file/index-html-generator.js +3 -3
- package/src/utils/index-file/inline-fonts.js +4 -4
- package/src/utils/load-esm.d.ts +22 -0
- package/src/utils/load-esm.js +37 -0
- package/src/utils/load-translations.js +21 -8
- package/src/utils/normalize-asset-patterns.js +8 -8
- package/src/utils/normalize-builder-schema.js +4 -4
- package/src/utils/normalize-file-replacements.js +10 -10
- package/src/utils/output-paths.js +3 -3
- package/src/utils/package-chunk-sort.js +1 -1
- package/src/utils/process-bundle.d.ts +0 -1
- package/src/utils/process-bundle.js +44 -12
- package/src/utils/read-tsconfig.js +6 -8
- package/src/utils/run-module-as-observable-fork.js +2 -2
- package/src/utils/service-worker.js +16 -9
- package/src/utils/spinner.js +2 -2
- package/src/utils/version.js +1 -1
- package/src/utils/webpack-browser-config.js +11 -11
- package/src/webpack/configs/browser.js +1 -1
- package/src/webpack/configs/common.js +16 -17
- package/src/webpack/configs/dev-server.d.ts +1 -1
- package/src/webpack/configs/dev-server.js +22 -10
- package/src/webpack/configs/server.js +2 -2
- package/src/webpack/configs/styles.js +4 -4
- package/src/webpack/configs/test.js +2 -2
- package/src/webpack/configs/typescript.js +1 -1
- package/src/webpack/configs/worker.js +1 -1
- package/src/webpack/plugins/any-component-style-budget-checker.js +4 -4
- package/src/webpack/plugins/common-js-usage-warn-plugin.js +2 -2
- package/src/webpack/plugins/css-optimizer-plugin.js +1 -1
- package/src/webpack/plugins/dedupe-module-resolve-plugin.js +1 -1
- package/src/webpack/plugins/esbuild-executor.js +1 -1
- package/src/webpack/plugins/hmr/hmr-accept.js +3 -3
- package/src/webpack/plugins/hmr/hmr-loader.js +1 -1
- package/src/webpack/plugins/index-html-webpack-plugin.js +6 -6
- package/src/webpack/plugins/javascript-optimizer-worker.js +2 -2
- package/src/webpack/plugins/karma/karma.js +4 -4
- package/src/webpack/plugins/postcss-cli-resources.js +1 -1
- package/src/webpack/plugins/scripts-webpack-plugin.js +1 -1
- package/src/webpack/plugins/single-test-transform.js +1 -1
- package/src/webpack/utils/stats.js +6 -6
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "13.0.0-next.
|
|
3
|
+
"version": "13.0.0-next.7",
|
|
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": "1.0.1",
|
|
10
|
-
"@angular-devkit/architect": "0.1300.0-next.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1300.0-next.
|
|
12
|
-
"@angular-devkit/core": "13.0.0-next.
|
|
10
|
+
"@angular-devkit/architect": "0.1300.0-next.7",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1300.0-next.7",
|
|
12
|
+
"@angular-devkit/core": "13.0.0-next.7",
|
|
13
13
|
"@babel/core": "7.15.5",
|
|
14
14
|
"@babel/generator": "7.15.4",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.15.4",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@babel/template": "7.15.4",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.5",
|
|
23
23
|
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
|
|
24
|
-
"@ngtools/webpack": "13.0.0-next.
|
|
24
|
+
"@ngtools/webpack": "13.0.0-next.7",
|
|
25
25
|
"ansi-colors": "4.1.1",
|
|
26
26
|
"babel-loader": "8.2.2",
|
|
27
27
|
"browserslist": "^4.9.1",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"caniuse-lite": "^1.0.30001032",
|
|
30
30
|
"circular-dependency-plugin": "5.2.2",
|
|
31
31
|
"copy-webpack-plugin": "9.0.1",
|
|
32
|
-
"core-js": "3.18.
|
|
32
|
+
"core-js": "3.18.1",
|
|
33
33
|
"critters": "0.0.10",
|
|
34
34
|
"css-loader": "6.3.0",
|
|
35
|
-
"esbuild-wasm": "0.
|
|
35
|
+
"esbuild-wasm": "0.13.3",
|
|
36
36
|
"find-cache-dir": "3.3.2",
|
|
37
|
-
"glob": "7.
|
|
37
|
+
"glob": "7.2.0",
|
|
38
38
|
"https-proxy-agent": "5.0.0",
|
|
39
39
|
"inquirer": "8.1.5",
|
|
40
40
|
"karma-source-map-support": "1.4.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"ora": "5.4.1",
|
|
49
49
|
"parse5-html-rewriting-stream": "6.0.1",
|
|
50
50
|
"piscina": "3.1.0",
|
|
51
|
-
"postcss": "8.3.
|
|
51
|
+
"postcss": "8.3.8",
|
|
52
52
|
"postcss-import": "14.0.2",
|
|
53
53
|
"postcss-loader": "6.1.1",
|
|
54
54
|
"postcss-preset-env": "6.7.0",
|
|
@@ -66,14 +66,14 @@
|
|
|
66
66
|
"text-table": "0.2.0",
|
|
67
67
|
"tree-kill": "1.2.2",
|
|
68
68
|
"tslib": "2.3.1",
|
|
69
|
-
"webpack": "5.
|
|
70
|
-
"webpack-dev-middleware": "5.1
|
|
71
|
-
"webpack-dev-server": "4.
|
|
69
|
+
"webpack": "5.55.1",
|
|
70
|
+
"webpack-dev-middleware": "5.2.1",
|
|
71
|
+
"webpack-dev-server": "4.3.0",
|
|
72
72
|
"webpack-merge": "5.8.0",
|
|
73
73
|
"webpack-subresource-integrity": "5.0.0"
|
|
74
74
|
},
|
|
75
75
|
"optionalDependencies": {
|
|
76
|
-
"esbuild": "0.
|
|
76
|
+
"esbuild": "0.13.3"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"@angular/compiler-cli": "^13.0.0 || ^13.0.0-next",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"ng-packagr": "^13.0.0 || ^13.0.0-next",
|
|
84
84
|
"protractor": "^7.0.0",
|
|
85
85
|
"tailwindcss": "^2.0.0",
|
|
86
|
-
"typescript": "~4.
|
|
86
|
+
"typescript": "~4.4.3"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"@angular/localize": {
|
|
@@ -208,7 +208,7 @@ function default_1() {
|
|
|
208
208
|
core_1.types.returnStatement(core_1.types.cloneNode(classNode.id)),
|
|
209
209
|
]));
|
|
210
210
|
const replacementInitializer = core_1.types.callExpression(core_1.types.parenthesizedExpression(container), []);
|
|
211
|
-
helper_annotate_as_pure_1.default(replacementInitializer);
|
|
211
|
+
(0, helper_annotate_as_pure_1.default)(replacementInitializer);
|
|
212
212
|
// Replace class with IIFE wrapped class
|
|
213
213
|
const declaration = core_1.types.variableDeclaration('let', [
|
|
214
214
|
core_1.types.variableDeclarator(core_1.types.cloneNode(classNode.id), replacementInitializer),
|
|
@@ -264,7 +264,7 @@ function default_1() {
|
|
|
264
264
|
core_1.types.returnStatement(core_1.types.cloneNode(classNode.id)),
|
|
265
265
|
]));
|
|
266
266
|
const replacementInitializer = core_1.types.callExpression(core_1.types.parenthesizedExpression(container), []);
|
|
267
|
-
helper_annotate_as_pure_1.default(replacementInitializer);
|
|
267
|
+
(0, helper_annotate_as_pure_1.default)(replacementInitializer);
|
|
268
268
|
// Add the wrapped class directly to the variable declaration
|
|
269
269
|
parentPath.get('init').replaceWith(replacementInitializer);
|
|
270
270
|
},
|
|
@@ -68,9 +68,15 @@ function default_1() {
|
|
|
68
68
|
if (!enumCallee.isFunctionExpression() || enumCallee.node.params.length !== 1) {
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
+
const enumCalleeParam = enumCallee.node.params[0];
|
|
72
|
+
const isEnumCalleeMatching = core_1.types.isIdentifier(enumCalleeParam) && enumCalleeParam.name === declarationId.name;
|
|
71
73
|
// Loose mode rewrites the enum to a shorter but less TypeScript-like form
|
|
74
|
+
// Note: We only can apply the `loose` mode transformation if the callee parameter matches
|
|
75
|
+
// with the declaration identifier name. This is necessary in case the the declaration id has
|
|
76
|
+
// been renamed to avoid collisions, as the loose transform would then break the enum assignments
|
|
77
|
+
// which rely on the differently-named callee identifier name.
|
|
72
78
|
let enumAssignments;
|
|
73
|
-
if (loose) {
|
|
79
|
+
if (loose && isEnumCalleeMatching) {
|
|
74
80
|
enumAssignments = [];
|
|
75
81
|
}
|
|
76
82
|
// Check if all enum member values are pure.
|
|
@@ -113,7 +119,7 @@ function default_1() {
|
|
|
113
119
|
core_1.types.returnStatement(core_1.types.cloneNode(declarationId)),
|
|
114
120
|
]));
|
|
115
121
|
const replacementInitializer = core_1.types.callExpression(core_1.types.parenthesizedExpression(container), []);
|
|
116
|
-
helper_annotate_as_pure_1.default(replacementInitializer);
|
|
122
|
+
(0, helper_annotate_as_pure_1.default)(replacementInitializer);
|
|
117
123
|
// Add the wrapped enum initializer directly to the variable declaration
|
|
118
124
|
declaration.get('init').replaceWith(replacementInitializer);
|
|
119
125
|
},
|
|
@@ -72,12 +72,12 @@ function default_1() {
|
|
|
72
72
|
if (core_1.types.isIdentifier(callee) && isTslibHelperName(callee.name)) {
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
|
-
helper_annotate_as_pure_1.default(path);
|
|
75
|
+
(0, helper_annotate_as_pure_1.default)(path);
|
|
76
76
|
},
|
|
77
77
|
NewExpression(path) {
|
|
78
78
|
// If the expression has a function parent, it is not top-level
|
|
79
79
|
if (!path.getFunctionParent()) {
|
|
80
|
-
helper_annotate_as_pure_1.default(path);
|
|
80
|
+
(0, helper_annotate_as_pure_1.default)(path);
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
},
|
|
@@ -6,15 +6,29 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
export declare type DiagnosticReporter = (type: 'error' | 'warning' | 'info', message: string) => void;
|
|
9
|
+
/**
|
|
10
|
+
* An interface representing the factory functions for the `@angular/localize` translation Babel plugins.
|
|
11
|
+
* This must be provided for the ESM imports since dynamic imports are required to be asynchronous and
|
|
12
|
+
* Babel presets currently can only be synchronous.
|
|
13
|
+
*
|
|
14
|
+
* TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
|
|
15
|
+
*/
|
|
16
|
+
export interface I18nPluginCreators {
|
|
17
|
+
makeEs2015TranslatePlugin: typeof import('@angular/localize/src/tools/src/translate/source_files/es2015_translate_plugin').makeEs2015TranslatePlugin;
|
|
18
|
+
makeEs5TranslatePlugin: typeof import('@angular/localize/src/tools/src/translate/source_files/es5_translate_plugin').makeEs5TranslatePlugin;
|
|
19
|
+
makeLocalePlugin: typeof import('@angular/localize/src/tools/src/translate/source_files/locale_plugin').makeLocalePlugin;
|
|
20
|
+
}
|
|
9
21
|
export interface ApplicationPresetOptions {
|
|
10
22
|
i18n?: {
|
|
11
23
|
locale: string;
|
|
12
24
|
missingTranslationBehavior?: 'error' | 'warning' | 'ignore';
|
|
13
25
|
translation?: unknown;
|
|
26
|
+
pluginCreators?: I18nPluginCreators;
|
|
14
27
|
};
|
|
15
28
|
angularLinker?: {
|
|
16
29
|
shouldLink: boolean;
|
|
17
30
|
jitMode: boolean;
|
|
31
|
+
linkerPluginCreator: typeof import('@angular/compiler-cli/linker/babel').createEs2015LinkerPlugin;
|
|
18
32
|
};
|
|
19
33
|
forceES5?: boolean;
|
|
20
34
|
forceAsyncTransformation?: boolean;
|
|
@@ -26,54 +26,62 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const assert_1 = require("assert");
|
|
29
30
|
const fs = __importStar(require("fs"));
|
|
30
31
|
const path = __importStar(require("path"));
|
|
31
32
|
function createI18nDiagnostics(reporter) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
const baseAdd = diagnostics.add;
|
|
38
|
-
diagnostics.add = function (type, message, ...args) {
|
|
39
|
-
if (type !== 'ignore') {
|
|
40
|
-
baseAdd.call(diagnostics, type, message, ...args);
|
|
41
|
-
reporter(type, message);
|
|
33
|
+
const diagnostics = new (class {
|
|
34
|
+
constructor() {
|
|
35
|
+
this.messages = [];
|
|
36
|
+
this.hasErrors = false;
|
|
42
37
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
diagnostics.warn = function (message, ...args) {
|
|
51
|
-
baseWarn.call(diagnostics, message, ...args);
|
|
52
|
-
reporter('warning', message);
|
|
53
|
-
};
|
|
54
|
-
const baseMerge = diagnostics.merge;
|
|
55
|
-
diagnostics.merge = function (other, ...args) {
|
|
56
|
-
baseMerge.call(diagnostics, other, ...args);
|
|
57
|
-
for (const diagnostic of other.messages) {
|
|
58
|
-
reporter(diagnostic.type, diagnostic.message);
|
|
38
|
+
add(type, message) {
|
|
39
|
+
if (type === 'ignore') {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
this.messages.push({ type, message });
|
|
43
|
+
this.hasErrors || (this.hasErrors = type === 'error');
|
|
44
|
+
reporter === null || reporter === void 0 ? void 0 : reporter(type, message);
|
|
59
45
|
}
|
|
60
|
-
|
|
46
|
+
error(message) {
|
|
47
|
+
this.add('error', message);
|
|
48
|
+
}
|
|
49
|
+
warn(message) {
|
|
50
|
+
this.add('warning', message);
|
|
51
|
+
}
|
|
52
|
+
merge(other) {
|
|
53
|
+
for (const diagnostic of other.messages) {
|
|
54
|
+
this.add(diagnostic.type, diagnostic.message);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
formatDiagnostics() {
|
|
58
|
+
assert_1.strict.fail('@angular/localize Diagnostics formatDiagnostics should not be called from within babel.');
|
|
59
|
+
}
|
|
60
|
+
})();
|
|
61
61
|
return diagnostics;
|
|
62
62
|
}
|
|
63
|
-
function createI18nPlugins(locale, translation, missingTranslationBehavior, diagnosticReporter
|
|
63
|
+
function createI18nPlugins(locale, translation, missingTranslationBehavior, diagnosticReporter,
|
|
64
|
+
// TODO_ESM: Make `pluginCreators` required once `@angular/localize` is published with the `tools` entry point
|
|
65
|
+
pluginCreators) {
|
|
64
66
|
const diagnostics = createI18nDiagnostics(diagnosticReporter);
|
|
65
67
|
const plugins = [];
|
|
66
68
|
if (translation) {
|
|
67
|
-
const { makeEs2015TranslatePlugin,
|
|
69
|
+
const { makeEs2015TranslatePlugin,
|
|
70
|
+
// TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
|
|
71
|
+
} = pluginCreators !== null && pluginCreators !== void 0 ? pluginCreators : require('@angular/localize/src/tools/src/translate/source_files/es2015_translate_plugin');
|
|
68
72
|
plugins.push(makeEs2015TranslatePlugin(diagnostics, translation, {
|
|
69
73
|
missingTranslation: missingTranslationBehavior,
|
|
70
74
|
}));
|
|
71
|
-
const { makeEs5TranslatePlugin,
|
|
75
|
+
const { makeEs5TranslatePlugin,
|
|
76
|
+
// TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
|
|
77
|
+
} = pluginCreators !== null && pluginCreators !== void 0 ? pluginCreators : require('@angular/localize/src/tools/src/translate/source_files/es5_translate_plugin');
|
|
72
78
|
plugins.push(makeEs5TranslatePlugin(diagnostics, translation, {
|
|
73
79
|
missingTranslation: missingTranslationBehavior,
|
|
74
80
|
}));
|
|
75
81
|
}
|
|
76
|
-
const { makeLocalePlugin,
|
|
82
|
+
const { makeLocalePlugin,
|
|
83
|
+
// TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
|
|
84
|
+
} = pluginCreators !== null && pluginCreators !== void 0 ? pluginCreators : require('@angular/localize/src/tools/src/translate/source_files/locale_plugin');
|
|
77
85
|
plugins.push(makeLocalePlugin(locale));
|
|
78
86
|
return plugins;
|
|
79
87
|
}
|
|
@@ -98,9 +106,7 @@ function default_1(api, options) {
|
|
|
98
106
|
const plugins = [];
|
|
99
107
|
let needRuntimeTransform = false;
|
|
100
108
|
if ((_a = options.angularLinker) === null || _a === void 0 ? void 0 : _a.shouldLink) {
|
|
101
|
-
|
|
102
|
-
const { createEs2015LinkerPlugin } = require('@angular/compiler-cli/linker/babel');
|
|
103
|
-
plugins.push(createEs2015LinkerPlugin({
|
|
109
|
+
plugins.push(options.angularLinker.linkerPluginCreator({
|
|
104
110
|
linkerJitMode: options.angularLinker.jitMode,
|
|
105
111
|
// This is a workaround until https://github.com/angular/angular/issues/42769 is fixed.
|
|
106
112
|
sourceMapping: false,
|
|
@@ -130,8 +136,8 @@ function default_1(api, options) {
|
|
|
130
136
|
needRuntimeTransform = true;
|
|
131
137
|
}
|
|
132
138
|
if (options.i18n) {
|
|
133
|
-
const { locale, missingTranslationBehavior, translation } = options.i18n;
|
|
134
|
-
const i18nPlugins = createI18nPlugins(locale, translation, missingTranslationBehavior || 'ignore', options.diagnosticReporter);
|
|
139
|
+
const { locale, missingTranslationBehavior, pluginCreators, translation } = options.i18n;
|
|
140
|
+
const i18nPlugins = createI18nPlugins(locale, translation, missingTranslationBehavior || 'ignore', options.diagnosticReporter, pluginCreators);
|
|
135
141
|
plugins.push(...i18nPlugins);
|
|
136
142
|
}
|
|
137
143
|
if (options.forceAsyncTransformation) {
|
|
@@ -7,18 +7,37 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const linker_1 = require("@angular/compiler-cli/linker");
|
|
11
10
|
const babel_loader_1 = require("babel-loader");
|
|
12
11
|
const typescript_1 = require("typescript");
|
|
13
|
-
|
|
12
|
+
const load_esm_1 = require("../utils/load-esm");
|
|
13
|
+
/**
|
|
14
|
+
* Cached instance of the compiler-cli linker's needsLinking function.
|
|
15
|
+
*/
|
|
16
|
+
let needsLinking;
|
|
17
|
+
/**
|
|
18
|
+
* Cached instance of the compiler-cli linker's Babel plugin factory function.
|
|
19
|
+
*/
|
|
20
|
+
let linkerPluginCreator;
|
|
21
|
+
/**
|
|
22
|
+
* Cached instance of the localize Babel plugins factory functions.
|
|
23
|
+
*/
|
|
24
|
+
let i18nPluginCreators;
|
|
25
|
+
async function requiresLinking(path, source) {
|
|
14
26
|
// @angular/core and @angular/compiler will cause false positives
|
|
15
27
|
// Also, TypeScript files do not require linking
|
|
16
28
|
if (/[\\/]@angular[\\/](?:compiler|core)|\.tsx?$/.test(path)) {
|
|
17
29
|
return false;
|
|
18
30
|
}
|
|
19
|
-
|
|
31
|
+
if (!needsLinking) {
|
|
32
|
+
// Load ESM `@angular/compiler-cli/linker` using the TypeScript dynamic import workaround.
|
|
33
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
34
|
+
// changed to a direct dynamic import.
|
|
35
|
+
const linkerModule = await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker');
|
|
36
|
+
needsLinking = linkerModule.needsLinking;
|
|
37
|
+
}
|
|
38
|
+
return needsLinking(path, source);
|
|
20
39
|
}
|
|
21
|
-
exports.default = babel_loader_1.custom(() => {
|
|
40
|
+
exports.default = (0, babel_loader_1.custom)(() => {
|
|
22
41
|
const baseOptions = Object.freeze({
|
|
23
42
|
babelrc: false,
|
|
24
43
|
configFile: false,
|
|
@@ -40,9 +59,17 @@ exports.default = babel_loader_1.custom(() => {
|
|
|
40
59
|
};
|
|
41
60
|
// Analyze file for linking
|
|
42
61
|
if (await requiresLinking(this.resourcePath, source)) {
|
|
62
|
+
if (!linkerPluginCreator) {
|
|
63
|
+
// Load ESM `@angular/compiler-cli/linker/babel` using the TypeScript dynamic import workaround.
|
|
64
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
65
|
+
// changed to a direct dynamic import.
|
|
66
|
+
const linkerBabelModule = await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker/babel');
|
|
67
|
+
linkerPluginCreator = linkerBabelModule.createEs2015LinkerPlugin;
|
|
68
|
+
}
|
|
43
69
|
customOptions.angularLinker = {
|
|
44
70
|
shouldLink: true,
|
|
45
71
|
jitMode: aot !== true,
|
|
72
|
+
linkerPluginCreator,
|
|
46
73
|
};
|
|
47
74
|
shouldProcess = true;
|
|
48
75
|
}
|
|
@@ -66,7 +93,25 @@ exports.default = babel_loader_1.custom(() => {
|
|
|
66
93
|
if (i18n &&
|
|
67
94
|
!/[\\/]@angular[\\/](?:compiler|localize)/.test(this.resourcePath) &&
|
|
68
95
|
source.includes('$localize')) {
|
|
69
|
-
|
|
96
|
+
// Load the i18n plugin creators from the new `@angular/localize/tools` entry point.
|
|
97
|
+
// This may fail during the transition to ESM due to the entry point not yet existing.
|
|
98
|
+
// During the transition, this will always attempt to load the entry point for each file.
|
|
99
|
+
// This will only occur during prerelease and will be automatically corrected once the new
|
|
100
|
+
// entry point exists.
|
|
101
|
+
// TODO_ESM: Make import failure an error once the `tools` entry point exists.
|
|
102
|
+
if (i18nPluginCreators === undefined) {
|
|
103
|
+
// Load ESM `@angular/localize/tools` using the TypeScript dynamic import workaround.
|
|
104
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
105
|
+
// changed to a direct dynamic import.
|
|
106
|
+
try {
|
|
107
|
+
i18nPluginCreators = await (0, load_esm_1.loadEsmModule)('@angular/localize/tools');
|
|
108
|
+
}
|
|
109
|
+
catch { }
|
|
110
|
+
}
|
|
111
|
+
customOptions.i18n = {
|
|
112
|
+
...i18n,
|
|
113
|
+
pluginCreators: i18nPluginCreators,
|
|
114
|
+
};
|
|
70
115
|
shouldProcess = true;
|
|
71
116
|
}
|
|
72
117
|
if (optimize) {
|
|
@@ -36,7 +36,7 @@ const service_worker_1 = require("../../utils/service-worker");
|
|
|
36
36
|
const spinner_1 = require("../../utils/spinner");
|
|
37
37
|
async function _renderUniversal(options, context, browserResult, serverResult, spinner) {
|
|
38
38
|
// Get browser target options.
|
|
39
|
-
const browserTarget = architect_1.targetFromTargetString(options.browserTarget);
|
|
39
|
+
const browserTarget = (0, architect_1.targetFromTargetString)(options.browserTarget);
|
|
40
40
|
const rawBrowserOptions = (await context.getTargetOptions(browserTarget));
|
|
41
41
|
const browserBuilderName = await context.getBuilderNameForTarget(browserTarget);
|
|
42
42
|
const browserOptions = await context.validateOptions(rawBrowserOptions, browserBuilderName);
|
|
@@ -49,8 +49,8 @@ async function _renderUniversal(options, context, browserResult, serverResult, s
|
|
|
49
49
|
throw new Error('The builder requires a target.');
|
|
50
50
|
}
|
|
51
51
|
const projectMetadata = await context.getProjectMetadata(projectName);
|
|
52
|
-
const projectRoot = core_1.resolve(core_1.normalize(root), core_1.normalize(projectMetadata.root || ''));
|
|
53
|
-
const { styles } = utils_1.normalizeOptimization(browserOptions.optimization);
|
|
52
|
+
const projectRoot = (0, core_1.resolve)((0, core_1.normalize)(root), (0, core_1.normalize)(projectMetadata.root || ''));
|
|
53
|
+
const { styles } = (0, utils_1.normalizeOptimization)(browserOptions.optimization);
|
|
54
54
|
const inlineCriticalCssProcessor = styles.inlineCritical
|
|
55
55
|
? new inline_critical_css_1.InlineCriticalCssProcessor({
|
|
56
56
|
minify: styles.minify,
|
|
@@ -91,7 +91,7 @@ async function _renderUniversal(options, context, browserResult, serverResult, s
|
|
|
91
91
|
}
|
|
92
92
|
await fs.promises.writeFile(outputIndexPath, html);
|
|
93
93
|
if (browserOptions.serviceWorker) {
|
|
94
|
-
await service_worker_1.augmentAppWithServiceWorker(core_1.normalize(root), projectRoot, core_1.normalize(outputPath), browserOptions.baseHref || '/', browserOptions.ngswConfigPath);
|
|
94
|
+
await (0, service_worker_1.augmentAppWithServiceWorker)((0, core_1.normalize)(root), projectRoot, (0, core_1.normalize)(outputPath), browserOptions.baseHref || '/', browserOptions.ngswConfigPath);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
return browserResult;
|
|
@@ -105,7 +105,7 @@ async function _getServerModuleBundlePath(options, context, serverResult, browse
|
|
|
105
105
|
if (!fs.existsSync(outputPath)) {
|
|
106
106
|
throw new Error(`Could not find server output directory: ${outputPath}.`);
|
|
107
107
|
}
|
|
108
|
-
const re = /^main\.(?:[a-zA-Z0-9]{
|
|
108
|
+
const re = /^main\.(?:[a-zA-Z0-9]{16}\.)?js$/;
|
|
109
109
|
const maybeMain = fs.readdirSync(outputPath).find((x) => re.test(x));
|
|
110
110
|
if (!maybeMain) {
|
|
111
111
|
throw new Error('Could not find the main bundle.');
|
|
@@ -113,12 +113,12 @@ async function _getServerModuleBundlePath(options, context, serverResult, browse
|
|
|
113
113
|
return path.join(outputPath, maybeMain);
|
|
114
114
|
}
|
|
115
115
|
async function _appShellBuilder(options, context) {
|
|
116
|
-
const browserTarget = architect_1.targetFromTargetString(options.browserTarget);
|
|
117
|
-
const serverTarget = architect_1.targetFromTargetString(options.serverTarget);
|
|
116
|
+
const browserTarget = (0, architect_1.targetFromTargetString)(options.browserTarget);
|
|
117
|
+
const serverTarget = (0, architect_1.targetFromTargetString)(options.serverTarget);
|
|
118
118
|
// Never run the browser target in watch mode.
|
|
119
119
|
// If service worker is needed, it will be added in _renderUniversal();
|
|
120
120
|
const browserOptions = (await context.getTargetOptions(browserTarget));
|
|
121
|
-
const optimization = utils_1.normalizeOptimization(browserOptions.optimization);
|
|
121
|
+
const optimization = (0, utils_1.normalizeOptimization)(browserOptions.optimization);
|
|
122
122
|
optimization.styles.inlineCritical = false;
|
|
123
123
|
const browserTargetRun = await context.scheduleTarget(browserTarget, {
|
|
124
124
|
watch: false,
|
|
@@ -154,4 +154,4 @@ async function _appShellBuilder(options, context) {
|
|
|
154
154
|
await Promise.all([browserTargetRun.stop(), serverTargetRun.stop()]);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
exports.default = architect_1.createBuilder(_appShellBuilder);
|
|
157
|
+
exports.default = (0, architect_1.createBuilder)(_appShellBuilder);
|