@angular-devkit/build-angular 14.2.0-rc.0 → 14.2.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 +12 -12
- package/src/builders/browser/index.js +14 -0
- package/src/builders/browser-esbuild/compiler-plugin.js +2 -2
- package/src/builders/browser-esbuild/index.js +77 -55
- package/src/builders/browser-esbuild/sass-plugin.js +4 -9
- package/src/builders/dev-server/index.js +0 -1
- package/src/webpack/configs/styles.js +20 -0
- package/src/webpack/plugins/postcss-cli-resources.js +2 -3
- package/src/webpack/plugins/service-worker-plugin.d.ts +0 -1
- package/src/webpack/plugins/service-worker-plugin.js +25 -7
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "14.2.
|
|
3
|
+
"version": "14.2.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.1402.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1402.
|
|
12
|
-
"@angular-devkit/core": "14.2.
|
|
10
|
+
"@angular-devkit/architect": "0.1402.2",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1402.2",
|
|
12
|
+
"@angular-devkit/core": "14.2.2",
|
|
13
13
|
"@babel/core": "7.18.10",
|
|
14
14
|
"@babel/generator": "7.18.12",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.18.6",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@babel/runtime": "7.18.9",
|
|
21
21
|
"@babel/template": "7.18.10",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.7",
|
|
23
|
-
"@ngtools/webpack": "14.2.
|
|
23
|
+
"@ngtools/webpack": "14.2.2",
|
|
24
24
|
"ansi-colors": "4.1.3",
|
|
25
25
|
"babel-loader": "8.2.5",
|
|
26
26
|
"babel-plugin-istanbul": "6.1.1",
|
|
@@ -46,7 +46,7 @@
|
|
|
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
51
|
"postcss-preset-env": "7.8.0",
|
|
52
52
|
"regenerator-runtime": "0.13.9",
|
|
@@ -65,7 +65,7 @@
|
|
|
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
|
},
|
|
@@ -73,14 +73,14 @@
|
|
|
73
73
|
"esbuild": "0.15.5"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@angular/compiler-cli": "^14.0.0
|
|
77
|
-
"@angular/localize": "^14.0.0
|
|
78
|
-
"@angular/service-worker": "^14.0.0
|
|
76
|
+
"@angular/compiler-cli": "^14.0.0",
|
|
77
|
+
"@angular/localize": "^14.0.0",
|
|
78
|
+
"@angular/service-worker": "^14.0.0",
|
|
79
79
|
"karma": "^6.3.0",
|
|
80
|
-
"ng-packagr": "^14.0.0
|
|
80
|
+
"ng-packagr": "^14.0.0",
|
|
81
81
|
"protractor": "^7.0.0",
|
|
82
82
|
"tailwindcss": "^2.0.0 || ^3.0.0",
|
|
83
|
-
"typescript": ">=4.6.2 <4.
|
|
83
|
+
"typescript": ">=4.6.2 <4.9"
|
|
84
84
|
},
|
|
85
85
|
"peerDependenciesMeta": {
|
|
86
86
|
"@angular/localize": {
|
|
@@ -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),
|
|
@@ -176,8 +176,8 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
176
176
|
// Once the AOT compiler allows only a transformResource hook, this can be reevaluated.
|
|
177
177
|
host.readResource = async function (fileName) {
|
|
178
178
|
var _a, _b, _c;
|
|
179
|
-
// Template resources (.html) files are not bundled or transformed
|
|
180
|
-
if (fileName.endsWith('.html')) {
|
|
179
|
+
// Template resources (.html/.svg) files are not bundled or transformed
|
|
180
|
+
if (fileName.endsWith('.html') || fileName.endsWith('.svg')) {
|
|
181
181
|
return (_a = this.readFile(fileName)) !== null && _a !== void 0 ? _a : '';
|
|
182
182
|
}
|
|
183
183
|
const { contents, resourceFiles, errors, warnings } = await (0, stylesheets_1.bundleStylesheetFile)(fileName, styleOptions);
|
|
@@ -57,7 +57,7 @@ const stylesheets_1 = require("./stylesheets");
|
|
|
57
57
|
*/
|
|
58
58
|
// eslint-disable-next-line max-lines-per-function
|
|
59
59
|
async function buildEsbuildBrowser(options, context) {
|
|
60
|
-
var _a, _b, _c, _d, _e, _f
|
|
60
|
+
var _a, _b, _c, _d, _e, _f;
|
|
61
61
|
const startTime = Date.now();
|
|
62
62
|
// Only AOT is currently supported
|
|
63
63
|
if (options.aot !== true) {
|
|
@@ -86,21 +86,28 @@ async function buildEsbuildBrowser(options, context) {
|
|
|
86
86
|
}
|
|
87
87
|
// Create reverse lookup used during index HTML generation
|
|
88
88
|
const entryPointNameLookup = new Map(Object.entries(entryPoints).map(([name, filePath]) => [path.relative(workspaceRoot, filePath), name]));
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
const [codeResults, styleResults] = await Promise.all([
|
|
90
|
+
// Execute esbuild to bundle the application code
|
|
91
|
+
bundleCode(workspaceRoot, entryPoints, outputNames, options, optimizationOptions, sourcemapOptions, tsconfig),
|
|
92
|
+
// Execute esbuild to bundle the global stylesheets
|
|
93
|
+
bundleGlobalStylesheets(workspaceRoot, outputNames, options, optimizationOptions, sourcemapOptions),
|
|
94
|
+
]);
|
|
91
95
|
// Log all warnings and errors generated during bundling
|
|
92
|
-
await (0, esbuild_1.logMessages)(context,
|
|
96
|
+
await (0, esbuild_1.logMessages)(context, {
|
|
97
|
+
errors: [...codeResults.errors, ...styleResults.errors],
|
|
98
|
+
warnings: [...codeResults.warnings, ...styleResults.warnings],
|
|
99
|
+
});
|
|
93
100
|
// Return if the bundling failed to generate output files or there are errors
|
|
94
|
-
if (!
|
|
101
|
+
if (!codeResults.outputFiles || codeResults.errors.length) {
|
|
95
102
|
return { success: false };
|
|
96
103
|
}
|
|
97
|
-
// Structure the bundling output files
|
|
104
|
+
// Structure the code bundling output files
|
|
98
105
|
const initialFiles = [];
|
|
99
106
|
const outputFiles = [];
|
|
100
|
-
for (const outputFile of
|
|
107
|
+
for (const outputFile of codeResults.outputFiles) {
|
|
101
108
|
// Entries in the metafile are relative to the `absWorkingDir` option which is set to the workspaceRoot
|
|
102
109
|
const relativeFilePath = path.relative(workspaceRoot, outputFile.path);
|
|
103
|
-
const entryPoint = (_c = (_b =
|
|
110
|
+
const entryPoint = (_c = (_b = codeResults.metafile) === null || _b === void 0 ? void 0 : _b.outputs[relativeFilePath]) === null || _c === void 0 ? void 0 : _c.entryPoint;
|
|
104
111
|
outputFile.path = relativeFilePath;
|
|
105
112
|
if (entryPoint) {
|
|
106
113
|
// An entryPoint value indicates an initial file
|
|
@@ -112,6 +119,13 @@ async function buildEsbuildBrowser(options, context) {
|
|
|
112
119
|
}
|
|
113
120
|
outputFiles.push(outputFile);
|
|
114
121
|
}
|
|
122
|
+
// Add global stylesheets output files
|
|
123
|
+
outputFiles.push(...styleResults.outputFiles);
|
|
124
|
+
initialFiles.push(...styleResults.initialFiles);
|
|
125
|
+
// Return if the global stylesheet bundling has errors
|
|
126
|
+
if (styleResults.errors.length) {
|
|
127
|
+
return { success: false };
|
|
128
|
+
}
|
|
115
129
|
// Create output directory if needed
|
|
116
130
|
try {
|
|
117
131
|
await fs_1.promises.mkdir(outputPath, { recursive: true });
|
|
@@ -121,56 +135,11 @@ async function buildEsbuildBrowser(options, context) {
|
|
|
121
135
|
context.logger.error('Unable to create output directory: ' + e.message);
|
|
122
136
|
return { success: false };
|
|
123
137
|
}
|
|
124
|
-
// Process global stylesheets
|
|
125
|
-
if (options.styles) {
|
|
126
|
-
// resolveGlobalStyles is temporarily reused from the Webpack builder code
|
|
127
|
-
const { entryPoints: stylesheetEntrypoints, noInjectNames } = (0, configs_1.resolveGlobalStyles)(options.styles, workspaceRoot,
|
|
128
|
-
// preserveSymlinks is always true here to allow the bundler to handle the option
|
|
129
|
-
true,
|
|
130
|
-
// skipResolution to leverage the bundler's more comprehensive resolution
|
|
131
|
-
true);
|
|
132
|
-
for (const [name, files] of Object.entries(stylesheetEntrypoints)) {
|
|
133
|
-
const virtualEntryData = files
|
|
134
|
-
.map((file) => `@import '${file.replace(/\\/g, '/')}';`)
|
|
135
|
-
.join('\n');
|
|
136
|
-
const sheetResult = await (0, stylesheets_1.bundleStylesheetText)(virtualEntryData, { virtualName: `angular:style/global;${name}`, resolvePath: workspaceRoot }, {
|
|
137
|
-
workspaceRoot,
|
|
138
|
-
optimization: !!optimizationOptions.styles.minify,
|
|
139
|
-
sourcemap: !!sourcemapOptions.styles && (sourcemapOptions.hidden ? 'external' : true),
|
|
140
|
-
outputNames: noInjectNames.includes(name) ? { media: outputNames.media } : outputNames,
|
|
141
|
-
includePaths: (_e = options.stylePreprocessorOptions) === null || _e === void 0 ? void 0 : _e.includePaths,
|
|
142
|
-
preserveSymlinks: options.preserveSymlinks,
|
|
143
|
-
externalDependencies: options.externalDependencies,
|
|
144
|
-
});
|
|
145
|
-
await (0, esbuild_1.logMessages)(context, sheetResult);
|
|
146
|
-
if (!sheetResult.path) {
|
|
147
|
-
// Failed to process the stylesheet
|
|
148
|
-
assert.ok(sheetResult.errors.length, `Global stylesheet processing for '${name}' failed with no errors.`);
|
|
149
|
-
return { success: false };
|
|
150
|
-
}
|
|
151
|
-
// The virtual stylesheets will be named `stdin` by esbuild. This must be replaced
|
|
152
|
-
// with the actual name of the global style and the leading directory separator must
|
|
153
|
-
// also be removed to make the path relative.
|
|
154
|
-
const sheetPath = sheetResult.path.replace('stdin', name);
|
|
155
|
-
outputFiles.push(createOutputFileFromText(sheetPath, sheetResult.contents));
|
|
156
|
-
if (sheetResult.map) {
|
|
157
|
-
outputFiles.push(createOutputFileFromText(sheetPath + '.map', sheetResult.map));
|
|
158
|
-
}
|
|
159
|
-
if (!noInjectNames.includes(name)) {
|
|
160
|
-
initialFiles.push({
|
|
161
|
-
file: sheetPath,
|
|
162
|
-
name,
|
|
163
|
-
extension: '.css',
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
outputFiles.push(...sheetResult.resourceFiles);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
138
|
// Generate index HTML file
|
|
170
139
|
if (options.index) {
|
|
171
140
|
const entrypoints = (0, package_chunk_sort_1.generateEntryPoints)({
|
|
172
|
-
scripts: (
|
|
173
|
-
styles: (
|
|
141
|
+
scripts: (_e = options.scripts) !== null && _e !== void 0 ? _e : [],
|
|
142
|
+
styles: (_f = options.styles) !== null && _f !== void 0 ? _f : [],
|
|
174
143
|
});
|
|
175
144
|
// Create an index HTML generator that reads from the in-memory output files
|
|
176
145
|
const indexHtmlGenerator = new index_html_generator_1.IndexHtmlGenerator({
|
|
@@ -301,4 +270,57 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
|
|
|
301
270
|
},
|
|
302
271
|
});
|
|
303
272
|
}
|
|
273
|
+
async function bundleGlobalStylesheets(workspaceRoot, outputNames, options, optimizationOptions, sourcemapOptions) {
|
|
274
|
+
var _a;
|
|
275
|
+
const outputFiles = [];
|
|
276
|
+
const initialFiles = [];
|
|
277
|
+
const errors = [];
|
|
278
|
+
const warnings = [];
|
|
279
|
+
// resolveGlobalStyles is temporarily reused from the Webpack builder code
|
|
280
|
+
const { entryPoints: stylesheetEntrypoints, noInjectNames } = (0, configs_1.resolveGlobalStyles)(options.styles || [], workspaceRoot,
|
|
281
|
+
// preserveSymlinks is always true here to allow the bundler to handle the option
|
|
282
|
+
true,
|
|
283
|
+
// skipResolution to leverage the bundler's more comprehensive resolution
|
|
284
|
+
true);
|
|
285
|
+
for (const [name, files] of Object.entries(stylesheetEntrypoints)) {
|
|
286
|
+
const virtualEntryData = files
|
|
287
|
+
.map((file) => `@import '${file.replace(/\\/g, '/')}';`)
|
|
288
|
+
.join('\n');
|
|
289
|
+
const sheetResult = await (0, stylesheets_1.bundleStylesheetText)(virtualEntryData, { virtualName: `angular:style/global;${name}`, resolvePath: workspaceRoot }, {
|
|
290
|
+
workspaceRoot,
|
|
291
|
+
optimization: !!optimizationOptions.styles.minify,
|
|
292
|
+
sourcemap: !!sourcemapOptions.styles && (sourcemapOptions.hidden ? 'external' : true),
|
|
293
|
+
outputNames: noInjectNames.includes(name) ? { media: outputNames.media } : outputNames,
|
|
294
|
+
includePaths: (_a = options.stylePreprocessorOptions) === null || _a === void 0 ? void 0 : _a.includePaths,
|
|
295
|
+
preserveSymlinks: options.preserveSymlinks,
|
|
296
|
+
externalDependencies: options.externalDependencies,
|
|
297
|
+
});
|
|
298
|
+
errors.push(...sheetResult.errors);
|
|
299
|
+
warnings.push(...sheetResult.warnings);
|
|
300
|
+
if (!sheetResult.path) {
|
|
301
|
+
// Failed to process the stylesheet
|
|
302
|
+
assert.ok(sheetResult.errors.length, `Global stylesheet processing for '${name}' failed with no errors.`);
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
// The virtual stylesheets will be named `stdin` by esbuild. This must be replaced
|
|
306
|
+
// with the actual name of the global style and the leading directory separator must
|
|
307
|
+
// also be removed to make the path relative.
|
|
308
|
+
const sheetPath = sheetResult.path.replace('stdin', name);
|
|
309
|
+
let sheetContents = sheetResult.contents;
|
|
310
|
+
if (sheetResult.map) {
|
|
311
|
+
outputFiles.push(createOutputFileFromText(sheetPath + '.map', sheetResult.map));
|
|
312
|
+
sheetContents = sheetContents.replace('sourceMappingURL=stdin.css.map', `sourceMappingURL=${name}.css.map`);
|
|
313
|
+
}
|
|
314
|
+
outputFiles.push(createOutputFileFromText(sheetPath, sheetContents));
|
|
315
|
+
if (!noInjectNames.includes(name)) {
|
|
316
|
+
initialFiles.push({
|
|
317
|
+
file: sheetPath,
|
|
318
|
+
name,
|
|
319
|
+
extension: '.css',
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
outputFiles.push(...sheetResult.resourceFiles);
|
|
323
|
+
}
|
|
324
|
+
return { outputFiles, initialFiles, errors, warnings };
|
|
325
|
+
}
|
|
304
326
|
exports.default = (0, architect_1.createBuilder)(buildEsbuildBrowser);
|
|
@@ -37,11 +37,9 @@ function createSassPlugin(options) {
|
|
|
37
37
|
name: 'angular-sass',
|
|
38
38
|
setup(build) {
|
|
39
39
|
let sass;
|
|
40
|
-
build.
|
|
41
|
-
// Lazily load Sass
|
|
42
|
-
sass = await Promise.resolve().then(() => __importStar(require('sass')));
|
|
43
|
-
});
|
|
44
|
-
build.onLoad({ filter: /\.s[ac]ss$/ }, (args) => {
|
|
40
|
+
build.onLoad({ filter: /\.s[ac]ss$/ }, async (args) => {
|
|
41
|
+
// Lazily load Sass when a Sass file is found
|
|
42
|
+
sass !== null && sass !== void 0 ? sass : (sass = await Promise.resolve().then(() => __importStar(require('sass'))));
|
|
45
43
|
try {
|
|
46
44
|
const warnings = [];
|
|
47
45
|
// Use sync version as async version is slower.
|
|
@@ -61,7 +59,7 @@ function createSassPlugin(options) {
|
|
|
61
59
|
});
|
|
62
60
|
return {
|
|
63
61
|
loader: 'css',
|
|
64
|
-
contents: `${css}\n${sourceMapToUrlComment(sourceMap)}
|
|
62
|
+
contents: sourceMap ? `${css}\n${sourceMapToUrlComment(sourceMap)}` : css,
|
|
65
63
|
watchFiles: loadedUrls.map((url) => (0, url_1.fileURLToPath)(url)),
|
|
66
64
|
warnings,
|
|
67
65
|
};
|
|
@@ -87,9 +85,6 @@ function createSassPlugin(options) {
|
|
|
87
85
|
}
|
|
88
86
|
exports.createSassPlugin = createSassPlugin;
|
|
89
87
|
function sourceMapToUrlComment(sourceMap) {
|
|
90
|
-
if (!sourceMap) {
|
|
91
|
-
return '';
|
|
92
|
-
}
|
|
93
88
|
const urlSourceMap = Buffer.from(JSON.stringify(sourceMap), 'utf-8').toString('base64');
|
|
94
89
|
return `/*# sourceMappingURL=data:application/json;charset=utf-8;base64,${urlSourceMap} */`;
|
|
95
90
|
}
|
|
@@ -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
|
}
|
|
@@ -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,
|
|
@@ -131,7 +131,7 @@ function default_1(options) {
|
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
133
|
const value = decl.value;
|
|
134
|
-
const urlRegex = /url(?:\(\s*['"]?)(.*?)(
|
|
134
|
+
const urlRegex = /url(?:\(\s*(['"]?))(.*?)(?:\1\s*\))/g;
|
|
135
135
|
const segments = [];
|
|
136
136
|
let match;
|
|
137
137
|
let lastIndex = 0;
|
|
@@ -139,9 +139,8 @@ function default_1(options) {
|
|
|
139
139
|
// We want to load it relative to the file that imports
|
|
140
140
|
const inputFile = decl.source && decl.source.input.file;
|
|
141
141
|
const context = (inputFile && path.dirname(inputFile)) || loader.context;
|
|
142
|
-
// eslint-disable-next-line no-cond-assign
|
|
143
142
|
while ((match = urlRegex.exec(value))) {
|
|
144
|
-
const originalUrl = match[
|
|
143
|
+
const originalUrl = match[2];
|
|
145
144
|
let processedUrl;
|
|
146
145
|
try {
|
|
147
146
|
processedUrl = await process(originalUrl, context, resourceCache);
|
|
@@ -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
|
}
|