@angular-devkit/build-angular 14.2.0 → 15.0.0-next.0
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 +23 -23
- package/src/builders/browser/index.js +14 -0
- package/src/builders/browser-esbuild/compiler-plugin.js +4 -6
- package/src/builders/browser-esbuild/index.js +13 -26
- package/src/builders/browser-esbuild/options.d.ts +2 -2
- package/src/builders/browser-esbuild/options.js +11 -2
- package/src/builders/dev-server/index.js +0 -1
- package/src/utils/load-translations.js +3 -12
- package/src/webpack/configs/styles.js +20 -0
- package/src/webpack/plugins/service-worker-plugin.d.ts +0 -1
- package/src/webpack/plugins/service-worker-plugin.js +25 -7
- package/src/webpack/plugins/typescript.js +0 -13
package/package.json
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0-next.0",
|
|
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.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.
|
|
12
|
-
"@angular-devkit/core": "
|
|
13
|
-
"@babel/core": "7.
|
|
14
|
-
"@babel/generator": "7.
|
|
10
|
+
"@angular-devkit/architect": "0.1500.0-next.0",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1500.0-next.0",
|
|
12
|
+
"@angular-devkit/core": "15.0.0-next.0",
|
|
13
|
+
"@babel/core": "7.19.0",
|
|
14
|
+
"@babel/generator": "7.19.0",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.18.6",
|
|
16
|
-
"@babel/plugin-proposal-async-generator-functions": "7.
|
|
16
|
+
"@babel/plugin-proposal-async-generator-functions": "7.19.0",
|
|
17
17
|
"@babel/plugin-transform-async-to-generator": "7.18.6",
|
|
18
18
|
"@babel/plugin-transform-runtime": "7.18.10",
|
|
19
|
-
"@babel/preset-env": "7.
|
|
20
|
-
"@babel/runtime": "7.
|
|
19
|
+
"@babel/preset-env": "7.19.0",
|
|
20
|
+
"@babel/runtime": "7.19.0",
|
|
21
21
|
"@babel/template": "7.18.10",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.7",
|
|
23
|
-
"@ngtools/webpack": "
|
|
23
|
+
"@ngtools/webpack": "15.0.0-next.0",
|
|
24
24
|
"ansi-colors": "4.1.3",
|
|
25
25
|
"babel-loader": "8.2.5",
|
|
26
26
|
"babel-plugin-istanbul": "6.1.1",
|
|
27
27
|
"browserslist": "^4.9.1",
|
|
28
|
-
"cacache": "16.1.
|
|
28
|
+
"cacache": "16.1.3",
|
|
29
29
|
"copy-webpack-plugin": "11.0.0",
|
|
30
30
|
"critters": "0.0.16",
|
|
31
31
|
"css-loader": "6.7.1",
|
|
32
|
-
"esbuild-wasm": "0.15.
|
|
32
|
+
"esbuild-wasm": "0.15.7",
|
|
33
33
|
"glob": "8.0.3",
|
|
34
34
|
"https-proxy-agent": "5.0.1",
|
|
35
35
|
"inquirer": "8.2.4",
|
|
36
|
-
"jsonc-parser": "3.
|
|
36
|
+
"jsonc-parser": "3.2.0",
|
|
37
37
|
"karma-source-map-support": "1.4.0",
|
|
38
38
|
"less": "4.1.3",
|
|
39
39
|
"less-loader": "11.0.0",
|
|
@@ -46,38 +46,38 @@
|
|
|
46
46
|
"parse5-html-rewriting-stream": "6.0.1",
|
|
47
47
|
"piscina": "3.2.0",
|
|
48
48
|
"postcss": "8.4.16",
|
|
49
|
-
"postcss-import": "
|
|
49
|
+
"postcss-import": "15.0.0",
|
|
50
50
|
"postcss-loader": "7.0.1",
|
|
51
|
-
"postcss-preset-env": "7.8.
|
|
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",
|
|
55
|
-
"sass": "1.54.
|
|
55
|
+
"sass": "1.54.9",
|
|
56
56
|
"sass-loader": "13.0.2",
|
|
57
57
|
"semver": "7.3.7",
|
|
58
58
|
"source-map-loader": "4.0.0",
|
|
59
59
|
"source-map-support": "0.5.21",
|
|
60
60
|
"stylus": "0.59.0",
|
|
61
61
|
"stylus-loader": "7.0.0",
|
|
62
|
-
"terser": "5.
|
|
62
|
+
"terser": "5.15.0",
|
|
63
63
|
"text-table": "0.2.0",
|
|
64
64
|
"tree-kill": "1.2.2",
|
|
65
65
|
"tslib": "2.4.0",
|
|
66
66
|
"webpack": "5.74.0",
|
|
67
67
|
"webpack-dev-middleware": "5.3.3",
|
|
68
|
-
"webpack-dev-server": "4.
|
|
68
|
+
"webpack-dev-server": "4.11.0",
|
|
69
69
|
"webpack-merge": "5.8.0",
|
|
70
70
|
"webpack-subresource-integrity": "5.1.0"
|
|
71
71
|
},
|
|
72
72
|
"optionalDependencies": {
|
|
73
|
-
"esbuild": "0.15.
|
|
73
|
+
"esbuild": "0.15.7"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@angular/compiler-cli": "^
|
|
77
|
-
"@angular/localize": "^
|
|
78
|
-
"@angular/service-worker": "^
|
|
76
|
+
"@angular/compiler-cli": "^15.0.0-next",
|
|
77
|
+
"@angular/localize": "^15.0.0-next",
|
|
78
|
+
"@angular/service-worker": "^15.0.0-next",
|
|
79
79
|
"karma": "^6.3.0",
|
|
80
|
-
"ng-packagr": "^
|
|
80
|
+
"ng-packagr": "^15.0.0-next",
|
|
81
81
|
"protractor": "^7.0.0",
|
|
82
82
|
"tailwindcss": "^2.0.0 || ^3.0.0",
|
|
83
83
|
"typescript": ">=4.6.2 <4.9"
|
|
@@ -105,12 +105,26 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
105
105
|
// Check Angular version.
|
|
106
106
|
(0, version_1.assertCompatibleAngularVersion)(context.workspaceRoot);
|
|
107
107
|
return (0, rxjs_1.from)(context.getProjectMetadata(projectName)).pipe((0, operators_1.switchMap)(async (projectMetadata) => {
|
|
108
|
+
var _a;
|
|
109
|
+
var _b;
|
|
108
110
|
// Purge old build disk cache.
|
|
109
111
|
await (0, purge_cache_1.purgeStaleBuildCache)(context);
|
|
110
112
|
// Initialize builder
|
|
111
113
|
const initialization = await initialize(options, context, transforms.webpackConfiguration);
|
|
112
114
|
// Check and warn about IE browser support
|
|
113
115
|
checkInternetExplorerSupport(initialization.projectRoot, context.logger);
|
|
116
|
+
// Add index file to watched files.
|
|
117
|
+
if (options.watch) {
|
|
118
|
+
const indexInputFile = path.join(context.workspaceRoot, (0, webpack_browser_config_1.getIndexInputFile)(options.index));
|
|
119
|
+
(_a = (_b = initialization.config).plugins) !== null && _a !== void 0 ? _a : (_b.plugins = []);
|
|
120
|
+
initialization.config.plugins.push({
|
|
121
|
+
apply: (compiler) => {
|
|
122
|
+
compiler.hooks.thisCompilation.tap('build-angular', (compilation) => {
|
|
123
|
+
compilation.fileDependencies.add(indexInputFile);
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}
|
|
114
128
|
return {
|
|
115
129
|
...initialization,
|
|
116
130
|
cacheOptions: (0, normalize_cache_1.normalizeCacheOptions)(projectMetadata, context.workspaceRoot),
|
|
@@ -134,7 +134,6 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
134
134
|
// The tsconfig is loaded in setup instead of in start to allow the esbuild target build option to be modified.
|
|
135
135
|
// esbuild build options can only be modified in setup prior to starting the build.
|
|
136
136
|
const { options: compilerOptions, rootNames, errors: configurationDiagnostics, } = compilerCli.readConfiguration(pluginOptions.tsconfig, {
|
|
137
|
-
enableIvy: true,
|
|
138
137
|
noEmitOnError: false,
|
|
139
138
|
suppressOutputPathCheck: true,
|
|
140
139
|
outDir: undefined,
|
|
@@ -176,8 +175,8 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
176
175
|
// Once the AOT compiler allows only a transformResource hook, this can be reevaluated.
|
|
177
176
|
host.readResource = async function (fileName) {
|
|
178
177
|
var _a, _b, _c;
|
|
179
|
-
// Template resources (.html) files are not bundled or transformed
|
|
180
|
-
if (fileName.endsWith('.html')) {
|
|
178
|
+
// Template resources (.html/.svg) files are not bundled or transformed
|
|
179
|
+
if (fileName.endsWith('.html') || fileName.endsWith('.svg')) {
|
|
181
180
|
return (_a = this.readFile(fileName)) !== null && _a !== void 0 ? _a : '';
|
|
182
181
|
}
|
|
183
182
|
const { contents, resourceFiles, errors, warnings } = await (0, stylesheets_1.bundleStylesheetFile)(fileName, styleOptions);
|
|
@@ -270,7 +269,7 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
270
269
|
};
|
|
271
270
|
}
|
|
272
271
|
const data = (_a = typescriptResult.content) !== null && _a !== void 0 ? _a : '';
|
|
273
|
-
const forceAsyncTransformation = /
|
|
272
|
+
const forceAsyncTransformation = /async\s+function\s*\*/.test(data);
|
|
274
273
|
const useInputSourcemap = pluginOptions.sourcemap &&
|
|
275
274
|
(!!pluginOptions.thirdPartySourcemaps || !/[\\/]node_modules[\\/]/.test(args.path));
|
|
276
275
|
// If no additional transformations are needed, return the TypeScript output directly
|
|
@@ -310,8 +309,7 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
310
309
|
build.onLoad({ filter: /\.[cm]?js$/ }, async (args) => {
|
|
311
310
|
var _a;
|
|
312
311
|
const data = await fs_1.promises.readFile(args.path, 'utf-8');
|
|
313
|
-
const forceAsyncTransformation = !/[\\/][_f]?esm2015[\\/]/.test(args.path) &&
|
|
314
|
-
/for\s+await\s*\(|async\s+function\s*\*/.test(data);
|
|
312
|
+
const forceAsyncTransformation = !/[\\/][_f]?esm2015[\\/]/.test(args.path) && /async\s+function\s*\*/.test(data);
|
|
315
313
|
const shouldLink = await (0, webpack_loader_1.requiresLinking)(args.path, data);
|
|
316
314
|
const useInputSourcemap = pluginOptions.sourcemap &&
|
|
317
315
|
(!!pluginOptions.thirdPartySourcemaps || !/[\\/]node_modules[\\/]/.test(args.path));
|
|
@@ -72,20 +72,20 @@ async function buildEsbuildBrowser(options, context) {
|
|
|
72
72
|
context.logger.error(`The 'browser-esbuild' builder requires a target to be specified.`);
|
|
73
73
|
return { success: false };
|
|
74
74
|
}
|
|
75
|
-
const { projectRoot, workspaceRoot,
|
|
75
|
+
const { projectRoot, workspaceRoot, entryPoints, entryPointNameLookup, optimizationOptions, outputPath, sourcemapOptions, tsconfig, assets, outputNames, } = await (0, options_1.normalizeOptions)(context, projectName, options);
|
|
76
76
|
// Clean output path if enabled
|
|
77
77
|
if (options.deleteOutputPath) {
|
|
78
78
|
(0, utils_1.deleteOutputDir)(workspaceRoot, options.outputPath);
|
|
79
79
|
}
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
// Create output directory if needed
|
|
81
|
+
try {
|
|
82
|
+
await fs_1.promises.mkdir(outputPath, { recursive: true });
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
(0, error_1.assertIsError)(e);
|
|
86
|
+
context.logger.error('Unable to create output directory: ' + e.message);
|
|
87
|
+
return { success: false };
|
|
86
88
|
}
|
|
87
|
-
// Create reverse lookup used during index HTML generation
|
|
88
|
-
const entryPointNameLookup = new Map(Object.entries(entryPoints).map(([name, filePath]) => [path.relative(workspaceRoot, filePath), name]));
|
|
89
89
|
const [codeResults, styleResults] = await Promise.all([
|
|
90
90
|
// Execute esbuild to bundle the application code
|
|
91
91
|
bundleCode(workspaceRoot, entryPoints, outputNames, options, optimizationOptions, sourcemapOptions, tsconfig),
|
|
@@ -126,15 +126,6 @@ async function buildEsbuildBrowser(options, context) {
|
|
|
126
126
|
if (styleResults.errors.length) {
|
|
127
127
|
return { success: false };
|
|
128
128
|
}
|
|
129
|
-
// Create output directory if needed
|
|
130
|
-
try {
|
|
131
|
-
await fs_1.promises.mkdir(outputPath, { recursive: true });
|
|
132
|
-
}
|
|
133
|
-
catch (e) {
|
|
134
|
-
(0, error_1.assertIsError)(e);
|
|
135
|
-
context.logger.error('Unable to create output directory: ' + e.message);
|
|
136
|
-
return { success: false };
|
|
137
|
-
}
|
|
138
129
|
// Generate index HTML file
|
|
139
130
|
if (options.index) {
|
|
140
131
|
const entrypoints = (0, package_chunk_sort_1.generateEntryPoints)({
|
|
@@ -216,15 +207,11 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
|
|
|
216
207
|
target: 'es2020',
|
|
217
208
|
supported: {
|
|
218
209
|
// Native async/await is not supported with Zone.js. Disabling support here will cause
|
|
219
|
-
// esbuild to downlevel async/await to a Zone.js supported form.
|
|
210
|
+
// esbuild to downlevel async/await and for await...of to a Zone.js supported form. However, esbuild
|
|
211
|
+
// does not currently support downleveling async generators. Instead babel is used within the JS/TS
|
|
212
|
+
// loader to perform the downlevel transformation.
|
|
213
|
+
// NOTE: If esbuild adds support in the future, the babel support for async generators can be disabled.
|
|
220
214
|
'async-await': false,
|
|
221
|
-
// Zone.js also does not support async generators or async iterators. However, esbuild does
|
|
222
|
-
// not currently support downleveling either of them. Instead babel is used within the JS/TS
|
|
223
|
-
// loader to perform the downlevel transformation. They are both disabled here to allow
|
|
224
|
-
// esbuild to handle them in the future if support is ever added.
|
|
225
|
-
// NOTE: If esbuild adds support in the future, the babel support for these can be disabled.
|
|
226
|
-
'async-generator': false,
|
|
227
|
-
'for-await': false,
|
|
228
215
|
},
|
|
229
216
|
mainFields: ['es2020', 'browser', 'module', 'main'],
|
|
230
217
|
conditions: ['es2020', 'es2015', 'module'],
|
|
@@ -19,8 +19,8 @@ import { Schema as BrowserBuilderOptions } from '../browser/schema';
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function normalizeOptions(context: BuilderContext, projectName: string, options: BrowserBuilderOptions): Promise<{
|
|
21
21
|
workspaceRoot: string;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
entryPoints: Record<string, string>;
|
|
23
|
+
entryPointNameLookup: ReadonlyMap<string, string>;
|
|
24
24
|
optimizationOptions: import("../../utils").NormalizedOptimizationOptions;
|
|
25
25
|
outputPath: string;
|
|
26
26
|
sourcemapOptions: import("../browser/schema").SourceMapClass;
|
|
@@ -71,10 +71,19 @@ async function normalizeOptions(context, projectName, options) {
|
|
|
71
71
|
if (options.resourcesOutputPath) {
|
|
72
72
|
outputNames.media = path.join(options.resourcesOutputPath, outputNames.media);
|
|
73
73
|
}
|
|
74
|
+
// Setup bundler entry points
|
|
75
|
+
const entryPoints = {
|
|
76
|
+
main: mainEntryPoint,
|
|
77
|
+
};
|
|
78
|
+
if (polyfillsEntryPoint) {
|
|
79
|
+
entryPoints['polyfills'] = polyfillsEntryPoint;
|
|
80
|
+
}
|
|
81
|
+
// Create reverse lookup used during index HTML generation
|
|
82
|
+
const entryPointNameLookup = new Map(Object.entries(entryPoints).map(([name, filePath]) => [path.relative(workspaceRoot, filePath), name]));
|
|
74
83
|
return {
|
|
75
84
|
workspaceRoot,
|
|
76
|
-
|
|
77
|
-
|
|
85
|
+
entryPoints,
|
|
86
|
+
entryPointNameLookup,
|
|
78
87
|
optimizationOptions,
|
|
79
88
|
outputPath,
|
|
80
89
|
sourcemapOptions,
|
|
@@ -191,7 +191,6 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
191
191
|
baseHref: browserOptions.baseHref,
|
|
192
192
|
root: context.workspaceRoot,
|
|
193
193
|
projectRoot,
|
|
194
|
-
outputPath: path.join(context.workspaceRoot, browserOptions.outputPath),
|
|
195
194
|
ngswConfigPath: browserOptions.ngswConfigPath,
|
|
196
195
|
}));
|
|
197
196
|
}
|
|
@@ -40,8 +40,10 @@ async function createTranslationLoader() {
|
|
|
40
40
|
const content = fs.readFileSync(path, 'utf8');
|
|
41
41
|
const unusedParsers = new Map();
|
|
42
42
|
for (const [format, parser] of Object.entries(parsers)) {
|
|
43
|
-
const analysis = analyze(
|
|
43
|
+
const analysis = parser.analyze(path, content);
|
|
44
44
|
if (analysis.canParse) {
|
|
45
|
+
// Types don't overlap here so we need to use any.
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
47
|
const { locale, translations } = parser.parse(path, content, analysis.hint);
|
|
46
48
|
const integrity = 'sha256-' + (0, crypto_1.createHash)('sha256').update(content).digest('base64');
|
|
47
49
|
return { format, locale, translations, diagnostics, integrity };
|
|
@@ -57,17 +59,6 @@ async function createTranslationLoader() {
|
|
|
57
59
|
throw new Error(`Unsupported translation file format in ${path}. The following parsers were tried:\n` +
|
|
58
60
|
messages.join('\n'));
|
|
59
61
|
};
|
|
60
|
-
// TODO: `parser.canParse()` is deprecated; remove this polyfill once we are sure all parsers provide the `parser.analyze()` method.
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
-
function analyze(parser, path, content) {
|
|
63
|
-
if (parser.analyze !== undefined) {
|
|
64
|
-
return parser.analyze(path, content);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
const hint = parser.canParse(path, content);
|
|
68
|
-
return { canParse: hint !== false, hint, diagnostics };
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
62
|
}
|
|
72
63
|
exports.createTranslationLoader = createTranslationLoader;
|
|
73
64
|
async function importParsers() {
|
|
@@ -37,6 +37,7 @@ exports.getStylesConfig = exports.resolveGlobalStyles = void 0;
|
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
39
39
|
const path = __importStar(require("path"));
|
|
40
|
+
const webpack_1 = require("webpack");
|
|
40
41
|
const sass_service_1 = require("../../sass/sass-service");
|
|
41
42
|
const plugins_1 = require("../plugins");
|
|
42
43
|
const css_optimizer_plugin_1 = require("../plugins/css-optimizer-plugin");
|
|
@@ -103,11 +104,18 @@ function getStylesConfig(wco) {
|
|
|
103
104
|
'To opt-out of the deprecated behaviour, please migrate to another stylesheet language.');
|
|
104
105
|
}
|
|
105
106
|
const sassImplementation = new sass_service_1.SassWorkerImplementation();
|
|
107
|
+
const sassTildeUsageMessage = new Set();
|
|
106
108
|
extraPlugins.push({
|
|
107
109
|
apply(compiler) {
|
|
108
110
|
compiler.hooks.shutdown.tap('sass-worker', () => {
|
|
109
111
|
sassImplementation.close();
|
|
110
112
|
});
|
|
113
|
+
compiler.hooks.afterCompile.tap('sass-worker', (compilation) => {
|
|
114
|
+
for (const message of sassTildeUsageMessage) {
|
|
115
|
+
compilation.warnings.push(new webpack_1.WebpackError(message));
|
|
116
|
+
}
|
|
117
|
+
sassTildeUsageMessage.clear();
|
|
118
|
+
});
|
|
111
119
|
},
|
|
112
120
|
});
|
|
113
121
|
const assetNameTemplate = (0, helpers_1.assetNameTemplateFactory)(hashFormat);
|
|
@@ -245,6 +253,12 @@ function getStylesConfig(wco) {
|
|
|
245
253
|
implementation: sassImplementation,
|
|
246
254
|
sourceMap: true,
|
|
247
255
|
sassOptions: {
|
|
256
|
+
importer: (url, from) => {
|
|
257
|
+
if (url.charAt(0) === '~') {
|
|
258
|
+
sassTildeUsageMessage.add(`'${from}' imports '${url}' with a tilde. Usage of '~' in imports is deprecated.`);
|
|
259
|
+
}
|
|
260
|
+
return null;
|
|
261
|
+
},
|
|
248
262
|
// Prevent use of `fibers` package as it no longer works in newer Node.js versions
|
|
249
263
|
fiber: false,
|
|
250
264
|
// bootstrap-sass requires a minimum precision of 8
|
|
@@ -277,6 +291,12 @@ function getStylesConfig(wco) {
|
|
|
277
291
|
implementation: sassImplementation,
|
|
278
292
|
sourceMap: true,
|
|
279
293
|
sassOptions: {
|
|
294
|
+
importer: (url, from) => {
|
|
295
|
+
if (url.charAt(0) === '~') {
|
|
296
|
+
sassTildeUsageMessage.add(`'${from}' imports '${url}' with a tilde. Usage of '~' in imports is deprecated.`);
|
|
297
|
+
}
|
|
298
|
+
return null;
|
|
299
|
+
},
|
|
280
300
|
// Prevent use of `fibers` package as it no longer works in newer Node.js versions
|
|
281
301
|
fiber: false,
|
|
282
302
|
indentedSyntax: true,
|
|
@@ -14,13 +14,31 @@ class ServiceWorkerPlugin {
|
|
|
14
14
|
this.options = options;
|
|
15
15
|
}
|
|
16
16
|
apply(compiler) {
|
|
17
|
-
compiler.hooks.done.tapPromise('angular-service-worker', async (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
compiler.hooks.done.tapPromise('angular-service-worker', async (stats) => {
|
|
18
|
+
if (stats.hasErrors()) {
|
|
19
|
+
// Don't generate a service worker if the compilation has errors.
|
|
20
|
+
// When there are errors some files will not be emitted which would cause other errors down the line such as readdir failures.
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const { projectRoot, root, baseHref = '', ngswConfigPath } = this.options;
|
|
24
|
+
const { compilation } = stats;
|
|
25
|
+
// We use the output path from the compilation instead of build options since during
|
|
26
|
+
// localization the output path is modified to a temp directory.
|
|
27
|
+
// See: https://github.com/angular/angular-cli/blob/7e64b1537d54fadb650559214fbb12707324cd75/packages/angular_devkit/build_angular/src/utils/i18n-options.ts#L251-L252
|
|
28
|
+
const outputPath = compilation.outputOptions.path;
|
|
29
|
+
if (!outputPath) {
|
|
30
|
+
throw new Error('Compilation output path cannot be empty.');
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, root, outputPath, baseHref, ngswConfigPath,
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
|
+
compiler.inputFileSystem.promises,
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
compiler.outputFileSystem.promises);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
compilation.errors.push(new compilation.compiler.webpack.WebpackError(`Failed to generate service worker - ${error instanceof Error ? error.message : error}`));
|
|
41
|
+
}
|
|
24
42
|
});
|
|
25
43
|
}
|
|
26
44
|
}
|
|
@@ -10,20 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.createIvyPlugin = void 0;
|
|
11
11
|
const webpack_1 = require("@ngtools/webpack");
|
|
12
12
|
const typescript_1 = require("typescript");
|
|
13
|
-
function ensureIvy(wco) {
|
|
14
|
-
if (wco.tsConfig.options.enableIvy !== false) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
wco.logger.warn('Project is attempting to disable the Ivy compiler. ' +
|
|
18
|
-
'Angular versions 12 and higher do not support the deprecated View Engine compiler for applications. ' +
|
|
19
|
-
'The Ivy compiler will be used to build this project. ' +
|
|
20
|
-
'\nFor additional information or if the build fails, please see https://angular.io/guide/ivy');
|
|
21
|
-
wco.tsConfig.options.enableIvy = true;
|
|
22
|
-
}
|
|
23
13
|
function createIvyPlugin(wco, aot, tsconfig) {
|
|
24
|
-
if (aot) {
|
|
25
|
-
ensureIvy(wco);
|
|
26
|
-
}
|
|
27
14
|
const { buildOptions } = wco;
|
|
28
15
|
const optimize = buildOptions.optimization.scripts;
|
|
29
16
|
const compilerOptions = {
|