@angular-devkit/build-angular 12.2.8 → 12.2.12
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 +11 -11
- package/src/babel/babel-loader.d.ts +12 -3
- package/src/babel/webpack-loader.js +24 -3
- package/src/browser/index.js +101 -98
- package/src/dev-server/index.js +3 -0
- package/src/utils/action-executor.js +4 -5
- package/src/utils/process-bundle.d.ts +3 -0
- package/src/utils/process-bundle.js +11 -5
- package/src/webpack/configs/browser.js +1 -0
- package/src/webpack/configs/common.js +1 -1
- package/src/webpack/configs/test.js +1 -0
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "12.2.
|
|
3
|
+
"version": "12.2.12",
|
|
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.1202.
|
|
11
|
-
"@angular-devkit/build-optimizer": "0.1202.
|
|
12
|
-
"@angular-devkit/build-webpack": "0.1202.
|
|
13
|
-
"@angular-devkit/core": "12.2.
|
|
10
|
+
"@angular-devkit/architect": "0.1202.12",
|
|
11
|
+
"@angular-devkit/build-optimizer": "0.1202.12",
|
|
12
|
+
"@angular-devkit/build-webpack": "0.1202.12",
|
|
13
|
+
"@angular-devkit/core": "12.2.12",
|
|
14
14
|
"@babel/core": "7.14.8",
|
|
15
15
|
"@babel/generator": "7.14.8",
|
|
16
16
|
"@babel/helper-annotate-as-pure": "7.14.5",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@babel/template": "7.14.5",
|
|
23
23
|
"@discoveryjs/json-ext": "0.5.3",
|
|
24
24
|
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
|
|
25
|
-
"@ngtools/webpack": "12.2.
|
|
25
|
+
"@ngtools/webpack": "12.2.12",
|
|
26
26
|
"ansi-colors": "4.1.1",
|
|
27
27
|
"babel-loader": "8.2.2",
|
|
28
28
|
"browserslist": "^4.9.1",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"circular-dependency-plugin": "5.2.2",
|
|
32
32
|
"copy-webpack-plugin": "9.0.1",
|
|
33
33
|
"core-js": "3.16.0",
|
|
34
|
-
"critters": "0.0.
|
|
34
|
+
"critters": "0.0.12",
|
|
35
35
|
"css-loader": "6.2.0",
|
|
36
36
|
"css-minimizer-webpack-plugin": "3.0.2",
|
|
37
|
-
"esbuild-wasm": "0.
|
|
37
|
+
"esbuild-wasm": "0.13.8",
|
|
38
38
|
"find-cache-dir": "3.3.1",
|
|
39
39
|
"glob": "7.1.7",
|
|
40
40
|
"https-proxy-agent": "5.0.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"less-loader": "10.0.1",
|
|
45
45
|
"license-webpack-plugin": "2.3.20",
|
|
46
46
|
"loader-utils": "2.0.0",
|
|
47
|
-
"mini-css-extract-plugin": "2.2
|
|
47
|
+
"mini-css-extract-plugin": "2.4.2",
|
|
48
48
|
"minimatch": "3.0.4",
|
|
49
49
|
"open": "8.2.1",
|
|
50
50
|
"ora": "5.4.1",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"webpack-subresource-integrity": "1.5.2"
|
|
78
78
|
},
|
|
79
79
|
"optionalDependencies": {
|
|
80
|
-
"esbuild": "0.
|
|
80
|
+
"esbuild": "0.13.8"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"@angular/compiler-cli": "^12.0.0",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
},
|
|
127
127
|
"engines": {
|
|
128
128
|
"node": "^12.14.1 || >=14.0.0",
|
|
129
|
-
"npm": "^6.11.0 || ^7.5.6",
|
|
129
|
+
"npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
|
|
130
130
|
"yarn": ">= 1.13.0"
|
|
131
131
|
},
|
|
132
132
|
"author": "Angular Authors",
|
|
@@ -7,9 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
declare module 'babel-loader' {
|
|
10
|
-
type BabelLoaderCustomizer<T> = (
|
|
11
|
-
babel: typeof import('@babel/core'),
|
|
12
|
-
) => {
|
|
10
|
+
type BabelLoaderCustomizer<T> = (babel: typeof import('@babel/core')) => {
|
|
13
11
|
customOptions?(
|
|
14
12
|
this: import('webpack').loader.LoaderContext,
|
|
15
13
|
loaderOptions: Record<string, unknown>,
|
|
@@ -20,6 +18,17 @@ declare module 'babel-loader' {
|
|
|
20
18
|
configuration: import('@babel/core').PartialConfig,
|
|
21
19
|
loaderArguments: { source: string; map?: unknown; customOptions: T },
|
|
22
20
|
): import('@babel/core').TransformOptions;
|
|
21
|
+
result?(
|
|
22
|
+
this: import('webpack').loader.LoaderContext,
|
|
23
|
+
result: import('@babel/core').BabelFileResult,
|
|
24
|
+
context: {
|
|
25
|
+
source: string;
|
|
26
|
+
map?: unknown;
|
|
27
|
+
customOptions: T;
|
|
28
|
+
configuration: import('@babel/core').PartialConfig;
|
|
29
|
+
options: import('@babel/core').TransformOptions;
|
|
30
|
+
},
|
|
31
|
+
): import('@babel/core').BabelFileResult;
|
|
23
32
|
};
|
|
24
33
|
function custom<T>(customizer: BabelLoaderCustomizer<T>): import('webpack').loader.Loader;
|
|
25
34
|
}
|
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
9
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
const remapping_1 = __importDefault(require("@ampproject/remapping"));
|
|
10
14
|
const linker_1 = require("@angular/compiler-cli/linker");
|
|
11
15
|
const babel_loader_1 = require("babel-loader");
|
|
12
16
|
const typescript_1 = require("typescript");
|
|
@@ -118,10 +122,10 @@ exports.default = babel_loader_1.custom(() => {
|
|
|
118
122
|
}
|
|
119
123
|
return {
|
|
120
124
|
...configuration.options,
|
|
121
|
-
//
|
|
122
|
-
//
|
|
125
|
+
// Using `false` disables babel from attempting to locate sourcemaps or process any inline maps.
|
|
126
|
+
// The babel types do not include the false option even though it is valid
|
|
123
127
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
124
|
-
inputSourceMap:
|
|
128
|
+
inputSourceMap: false,
|
|
125
129
|
plugins,
|
|
126
130
|
presets: [
|
|
127
131
|
...(configuration.options.presets || []),
|
|
@@ -146,5 +150,22 @@ exports.default = babel_loader_1.custom(() => {
|
|
|
146
150
|
],
|
|
147
151
|
};
|
|
148
152
|
},
|
|
153
|
+
result(result, { map: inputSourceMap }) {
|
|
154
|
+
if (result.map && inputSourceMap) {
|
|
155
|
+
// Merge the intermediate sourcemap generated by babel with the input source map.
|
|
156
|
+
// The casting is required due to slight differences in the types for babel and
|
|
157
|
+
// `@ampproject/remapping` source map objects but both are compatible with Webpack.
|
|
158
|
+
// This method for merging is used because it provides more accurate output
|
|
159
|
+
// and is faster while using less memory.
|
|
160
|
+
result.map = {
|
|
161
|
+
// Convert the SourceMap back to simple plain object.
|
|
162
|
+
// This is needed because otherwise code-coverage will fail with `don't know how to turn this value into a node`
|
|
163
|
+
// Which is throw by Babel when it is invoked again from `istanbul-lib-instrument`.
|
|
164
|
+
// https://github.com/babel/babel/blob/780aa48d2a34dc55f556843074b6aed45e7eabeb/packages/babel-types/src/converters/valueToNode.ts#L115-L130
|
|
165
|
+
...remapping_1.default([result.map, inputSourceMap], () => null),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
},
|
|
149
170
|
};
|
|
150
171
|
});
|
package/src/browser/index.js
CHANGED
|
@@ -131,7 +131,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
131
131
|
}).pipe(
|
|
132
132
|
// eslint-disable-next-line max-lines-per-function
|
|
133
133
|
operators_1.concatMap(async (buildEvent) => {
|
|
134
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
134
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
135
135
|
const spinner = new spinner_1.Spinner();
|
|
136
136
|
spinner.enabled = options.progress !== false;
|
|
137
137
|
const { success, emittedFiles = [], outputPath: webpackOutputPath } = buildEvent;
|
|
@@ -241,7 +241,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
241
241
|
if (actionOptions.sourceMaps) {
|
|
242
242
|
try {
|
|
243
243
|
map = fs.readFileSync(filename + '.map', 'utf8');
|
|
244
|
-
if (es5Polyfills) {
|
|
244
|
+
if (es5Polyfills || i18n.shouldInline) {
|
|
245
245
|
fs.unlinkSync(filename + '.map');
|
|
246
246
|
}
|
|
247
247
|
}
|
|
@@ -251,6 +251,11 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
251
251
|
fs.unlinkSync(filename);
|
|
252
252
|
filename = filename.replace(/\-es20\d{2}/, '');
|
|
253
253
|
}
|
|
254
|
+
else if (i18n.shouldInline) {
|
|
255
|
+
// Original files must be deleted with i18n to avoid the original files from
|
|
256
|
+
// being copied over the translated files when copying the project assets.
|
|
257
|
+
fs.unlinkSync(filename);
|
|
258
|
+
}
|
|
254
259
|
const es2015Polyfills = file.file.startsWith('polyfills-es20');
|
|
255
260
|
// Record the bundle processing action
|
|
256
261
|
// The runtime chunk gets special processing for lazy loaded files
|
|
@@ -265,6 +270,8 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
265
270
|
runtime: file.file.startsWith('runtime'),
|
|
266
271
|
ignoreOriginal: es5Polyfills,
|
|
267
272
|
optimizeOnly: es2015Polyfills,
|
|
273
|
+
// When using i18n, file results are kept in memory for further processing
|
|
274
|
+
memoryMode: i18n.shouldInline,
|
|
268
275
|
});
|
|
269
276
|
// ES2015 polyfills are only optimized; optimization check was performed above
|
|
270
277
|
if (es2015Polyfills) {
|
|
@@ -288,109 +295,105 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
288
295
|
processActions.push({ replacements: workerReplacements, ...action });
|
|
289
296
|
}
|
|
290
297
|
}
|
|
291
|
-
const
|
|
298
|
+
const differentialLoadingExecutor = new action_executor_1.BundleActionExecutor({ cachePath: cacheDownlevelPath, i18n }, options.subresourceIntegrity ? 'sha384' : undefined);
|
|
292
299
|
// Execute the bundle processing actions
|
|
293
300
|
try {
|
|
294
301
|
spinner.start('Generating ES5 bundles for differential loading...');
|
|
295
|
-
for await (const result of
|
|
302
|
+
for await (const result of differentialLoadingExecutor.processAll(processActions)) {
|
|
296
303
|
processResults.push(result);
|
|
297
304
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
305
|
+
}
|
|
306
|
+
finally {
|
|
307
|
+
differentialLoadingExecutor.stop();
|
|
308
|
+
}
|
|
309
|
+
// Runtime must be processed after all other files
|
|
310
|
+
if (processRuntimeAction) {
|
|
311
|
+
const runtimeOptions = {
|
|
312
|
+
...processRuntimeAction,
|
|
313
|
+
runtimeData: processResults,
|
|
314
|
+
supportedBrowsers: buildBrowserFeatures.supportedBrowsers,
|
|
315
|
+
};
|
|
316
|
+
processResults.push(await Promise.resolve().then(() => __importStar(require('../utils/process-bundle'))).then((m) => m.process(runtimeOptions)));
|
|
317
|
+
}
|
|
318
|
+
spinner.succeed('ES5 bundle generation complete.');
|
|
319
|
+
if (i18n.shouldInline) {
|
|
320
|
+
spinner.start('Generating localized bundles...');
|
|
321
|
+
const inlineActions = [];
|
|
322
|
+
for (const result of processResults) {
|
|
323
|
+
if (result.original) {
|
|
324
|
+
inlineActions.push({
|
|
325
|
+
filename: path.basename(result.original.filename),
|
|
326
|
+
// Memory mode is always enabled for i18n
|
|
327
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
328
|
+
code: result.original.content,
|
|
329
|
+
map: (_a = result.original.map) === null || _a === void 0 ? void 0 : _a.content,
|
|
330
|
+
outputPath: baseOutputPath,
|
|
331
|
+
es5: false,
|
|
332
|
+
missingTranslation: options.i18nMissingTranslation,
|
|
333
|
+
setLocale: result.name === mainChunkId,
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
if (result.downlevel) {
|
|
337
|
+
inlineActions.push({
|
|
338
|
+
filename: path.basename(result.downlevel.filename),
|
|
339
|
+
// Memory mode is always enabled for i18n
|
|
340
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
341
|
+
code: result.downlevel.content,
|
|
342
|
+
map: (_b = result.downlevel.map) === null || _b === void 0 ? void 0 : _b.content,
|
|
343
|
+
outputPath: baseOutputPath,
|
|
344
|
+
es5: true,
|
|
345
|
+
missingTranslation: options.i18nMissingTranslation,
|
|
346
|
+
setLocale: result.name === mainChunkId,
|
|
347
|
+
});
|
|
348
|
+
}
|
|
306
349
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
const inlineActions
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
if (result.original) {
|
|
314
|
-
inlineActions.push({
|
|
315
|
-
filename: path.basename(result.original.filename),
|
|
316
|
-
code: fs.readFileSync(result.original.filename, 'utf8'),
|
|
317
|
-
map: result.original.map &&
|
|
318
|
-
fs.readFileSync(result.original.map.filename, 'utf8'),
|
|
319
|
-
outputPath: baseOutputPath,
|
|
320
|
-
es5: false,
|
|
321
|
-
missingTranslation: options.i18nMissingTranslation,
|
|
322
|
-
setLocale: result.name === mainChunkId,
|
|
323
|
-
});
|
|
324
|
-
processedFiles.add(result.original.filename);
|
|
325
|
-
if (result.original.map) {
|
|
326
|
-
processedFiles.add(result.original.map.filename);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
if (result.downlevel) {
|
|
330
|
-
inlineActions.push({
|
|
331
|
-
filename: path.basename(result.downlevel.filename),
|
|
332
|
-
code: fs.readFileSync(result.downlevel.filename, 'utf8'),
|
|
333
|
-
map: result.downlevel.map &&
|
|
334
|
-
fs.readFileSync(result.downlevel.map.filename, 'utf8'),
|
|
335
|
-
outputPath: baseOutputPath,
|
|
336
|
-
es5: true,
|
|
337
|
-
missingTranslation: options.i18nMissingTranslation,
|
|
338
|
-
setLocale: result.name === mainChunkId,
|
|
339
|
-
});
|
|
340
|
-
processedFiles.add(result.downlevel.filename);
|
|
341
|
-
if (result.downlevel.map) {
|
|
342
|
-
processedFiles.add(result.downlevel.map.filename);
|
|
343
|
-
}
|
|
350
|
+
let hasErrors = false;
|
|
351
|
+
const i18nExecutor = new action_executor_1.BundleActionExecutor({ i18n }, options.subresourceIntegrity ? 'sha384' : undefined);
|
|
352
|
+
try {
|
|
353
|
+
for await (const result of i18nExecutor.inlineAll(inlineActions)) {
|
|
354
|
+
if (options.verbose) {
|
|
355
|
+
context.logger.info(`Localized "${result.file}" [${result.count} translation(s)].`);
|
|
344
356
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
context.logger.info(`Localized "${result.file}" [${result.count} translation(s)].`);
|
|
357
|
+
for (const diagnostic of result.diagnostics) {
|
|
358
|
+
spinner.stop();
|
|
359
|
+
if (diagnostic.type === 'error') {
|
|
360
|
+
hasErrors = true;
|
|
361
|
+
context.logger.error(diagnostic.message);
|
|
351
362
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
if (diagnostic.type === 'error') {
|
|
355
|
-
hasErrors = true;
|
|
356
|
-
context.logger.error(diagnostic.message);
|
|
357
|
-
}
|
|
358
|
-
else {
|
|
359
|
-
context.logger.warn(diagnostic.message);
|
|
360
|
-
}
|
|
361
|
-
spinner.start();
|
|
363
|
+
else {
|
|
364
|
+
context.logger.warn(diagnostic.message);
|
|
362
365
|
}
|
|
366
|
+
spinner.start();
|
|
363
367
|
}
|
|
364
|
-
// Copy any non-processed files into the output locations
|
|
365
|
-
await copy_assets_1.copyAssets([
|
|
366
|
-
{
|
|
367
|
-
glob: '**/*',
|
|
368
|
-
input: webpackOutputPath,
|
|
369
|
-
output: '',
|
|
370
|
-
ignore: [...processedFiles].map((f) => path.relative(webpackOutputPath, f)),
|
|
371
|
-
},
|
|
372
|
-
], Array.from(outputPaths.values()), '');
|
|
373
|
-
}
|
|
374
|
-
catch (err) {
|
|
375
|
-
spinner.fail('Localized bundle generation failed.');
|
|
376
|
-
return { success: false, error: mapErrorToMessage(err) };
|
|
377
|
-
}
|
|
378
|
-
if (hasErrors) {
|
|
379
|
-
spinner.fail('Localized bundle generation failed.');
|
|
380
|
-
}
|
|
381
|
-
else {
|
|
382
|
-
spinner.succeed('Localized bundle generation complete.');
|
|
383
|
-
}
|
|
384
|
-
if (hasErrors) {
|
|
385
|
-
return { success: false };
|
|
386
368
|
}
|
|
369
|
+
// Copy any non-processed files into the output locations
|
|
370
|
+
await copy_assets_1.copyAssets([
|
|
371
|
+
{
|
|
372
|
+
glob: '**/*',
|
|
373
|
+
input: webpackOutputPath,
|
|
374
|
+
output: '',
|
|
375
|
+
},
|
|
376
|
+
], Array.from(outputPaths.values()), '');
|
|
377
|
+
}
|
|
378
|
+
catch (err) {
|
|
379
|
+
spinner.fail('Localized bundle generation failed.');
|
|
380
|
+
return { success: false, error: mapErrorToMessage(err) };
|
|
381
|
+
}
|
|
382
|
+
finally {
|
|
383
|
+
i18nExecutor.stop();
|
|
384
|
+
}
|
|
385
|
+
if (hasErrors) {
|
|
386
|
+
spinner.fail('Localized bundle generation failed.');
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
spinner.succeed('Localized bundle generation complete.');
|
|
390
|
+
}
|
|
391
|
+
if (hasErrors) {
|
|
392
|
+
return { success: false };
|
|
387
393
|
}
|
|
388
|
-
}
|
|
389
|
-
finally {
|
|
390
|
-
executor.stop();
|
|
391
394
|
}
|
|
392
395
|
for (const result of processResults) {
|
|
393
|
-
const chunk = (
|
|
396
|
+
const chunk = (_c = webpackStats.chunks) === null || _c === void 0 ? void 0 : _c.find((chunk) => { var _a; return ((_a = chunk.id) === null || _a === void 0 ? void 0 : _a.toString()) === result.name; });
|
|
394
397
|
if (result.original) {
|
|
395
398
|
bundleInfoStats.push(generateBundleInfoStats(result.original, chunk, 'modern'));
|
|
396
399
|
}
|
|
@@ -398,9 +401,9 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
398
401
|
bundleInfoStats.push(generateBundleInfoStats(result.downlevel, chunk, 'legacy'));
|
|
399
402
|
}
|
|
400
403
|
}
|
|
401
|
-
const unprocessedChunks = ((
|
|
404
|
+
const unprocessedChunks = ((_d = webpackStats.chunks) === null || _d === void 0 ? void 0 : _d.filter((chunk) => !processResults.find((result) => { var _a; return ((_a = chunk.id) === null || _a === void 0 ? void 0 : _a.toString()) === result.name; }))) || [];
|
|
402
405
|
for (const chunk of unprocessedChunks) {
|
|
403
|
-
const asset = (
|
|
406
|
+
const asset = (_e = webpackStats.assets) === null || _e === void 0 ? void 0 : _e.find((a) => { var _a; return a.name === ((_a = chunk.files) === null || _a === void 0 ? void 0 : _a[0]); });
|
|
404
407
|
bundleInfoStats.push(stats_1.generateBundleStats({ ...chunk, size: asset === null || asset === void 0 ? void 0 : asset.size }));
|
|
405
408
|
}
|
|
406
409
|
}
|
|
@@ -421,10 +424,10 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
421
424
|
for (const { severity, message } of budgetFailures) {
|
|
422
425
|
switch (severity) {
|
|
423
426
|
case bundle_calculator_1.ThresholdSeverity.Warning:
|
|
424
|
-
(
|
|
427
|
+
(_f = webpackStats.warnings) === null || _f === void 0 ? void 0 : _f.push({ message });
|
|
425
428
|
break;
|
|
426
429
|
case bundle_calculator_1.ThresholdSeverity.Error:
|
|
427
|
-
(
|
|
430
|
+
(_g = webpackStats.errors) === null || _g === void 0 ? void 0 : _g.push({ message });
|
|
428
431
|
break;
|
|
429
432
|
default:
|
|
430
433
|
assertNever(severity);
|
|
@@ -434,7 +437,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
434
437
|
const buildSuccess = success && !stats_1.statsHasErrors(webpackStats);
|
|
435
438
|
if (buildSuccess) {
|
|
436
439
|
// Copy assets
|
|
437
|
-
if (!options.watch && ((
|
|
440
|
+
if (!options.watch && ((_h = options.assets) === null || _h === void 0 ? void 0 : _h.length)) {
|
|
438
441
|
spinner.start('Copying assets...');
|
|
439
442
|
try {
|
|
440
443
|
await copy_assets_1.copyAssets(utils_1.normalizeAssetPatterns(options.assets, root, core_1.normalize(projectRoot), projectSourceRoot === undefined ? undefined : core_1.normalize(projectSourceRoot)), Array.from(outputPaths.values()), context.workspaceRoot);
|
|
@@ -449,8 +452,8 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
449
452
|
spinner.start('Generating index html...');
|
|
450
453
|
const WOFFSupportNeeded = !buildBrowserFeatures.isFeatureSupported('woff2');
|
|
451
454
|
const entrypoints = package_chunk_sort_1.generateEntryPoints({
|
|
452
|
-
scripts: (
|
|
453
|
-
styles: (
|
|
455
|
+
scripts: (_j = options.scripts) !== null && _j !== void 0 ? _j : [],
|
|
456
|
+
styles: (_k = options.styles) !== null && _k !== void 0 ? _k : [],
|
|
454
457
|
});
|
|
455
458
|
const indexHtmlGenerator = new index_html_generator_1.IndexHtmlGenerator({
|
|
456
459
|
indexPath: path.join(context.workspaceRoot, webpack_browser_config_1.getIndexInputFile(options.index)),
|
package/src/dev-server/index.js
CHANGED
|
@@ -274,6 +274,9 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
274
274
|
if (buildEvent.success) {
|
|
275
275
|
logger.info(`\n${color_1.colors.greenBright(color_1.colors.symbols.check)} Compiled successfully.`);
|
|
276
276
|
}
|
|
277
|
+
else {
|
|
278
|
+
logger.info(`\n${color_1.colors.redBright(color_1.colors.symbols.cross)} Failed to compile.`);
|
|
279
|
+
}
|
|
277
280
|
return { ...buildEvent, baseUrl: serverAddress };
|
|
278
281
|
}));
|
|
279
282
|
}));
|
|
@@ -62,13 +62,12 @@ class BundleActionExecutor {
|
|
|
62
62
|
const executions = new Map();
|
|
63
63
|
for (const action of actions) {
|
|
64
64
|
const execution = executor(action);
|
|
65
|
-
executions.set(execution, execution.then((result) =>
|
|
66
|
-
executions.delete(execution);
|
|
67
|
-
return result;
|
|
68
|
-
}));
|
|
65
|
+
executions.set(execution, execution.then((result) => [execution, result]));
|
|
69
66
|
}
|
|
70
67
|
while (executions.size > 0) {
|
|
71
|
-
|
|
68
|
+
const [execution, result] = await Promise.race(executions.values());
|
|
69
|
+
executions.delete(execution);
|
|
70
|
+
yield result;
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
stop() {
|
|
@@ -24,6 +24,7 @@ export interface ProcessBundleOptions {
|
|
|
24
24
|
runtimeData?: ProcessBundleResult[];
|
|
25
25
|
replacements?: [string, string][];
|
|
26
26
|
supportedBrowsers?: string[] | Record<string, string>;
|
|
27
|
+
memoryMode?: boolean;
|
|
27
28
|
}
|
|
28
29
|
export interface ProcessBundleResult {
|
|
29
30
|
name: string;
|
|
@@ -35,9 +36,11 @@ export interface ProcessBundleFile {
|
|
|
35
36
|
filename: string;
|
|
36
37
|
size: number;
|
|
37
38
|
integrity?: string;
|
|
39
|
+
content?: string;
|
|
38
40
|
map?: {
|
|
39
41
|
filename: string;
|
|
40
42
|
size: number;
|
|
43
|
+
content?: string;
|
|
41
44
|
};
|
|
42
45
|
}
|
|
43
46
|
export declare const enum CacheKey {
|
|
@@ -134,7 +134,7 @@ async function process(options) {
|
|
|
134
134
|
}
|
|
135
135
|
exports.process = process;
|
|
136
136
|
async function processBundle(options) {
|
|
137
|
-
const { optimize, isOriginal, code, map, downlevelMap, filename: filepath, hiddenSourceMaps, cacheKeys = [], integrityAlgorithm, } = options;
|
|
137
|
+
const { optimize, isOriginal, code, map, downlevelMap, filename: filepath, hiddenSourceMaps, cacheKeys = [], integrityAlgorithm, memoryMode, } = options;
|
|
138
138
|
const filename = path.basename(filepath);
|
|
139
139
|
let resultCode = code;
|
|
140
140
|
let optimizeResult;
|
|
@@ -168,11 +168,15 @@ async function processBundle(options) {
|
|
|
168
168
|
mapContent = map;
|
|
169
169
|
}
|
|
170
170
|
await cachePut(mapContent, cacheKeys[isOriginal ? 1 /* OriginalMap */ : 3 /* DownlevelMap */]);
|
|
171
|
-
|
|
171
|
+
if (!memoryMode) {
|
|
172
|
+
fs.writeFileSync(filepath + '.map', mapContent);
|
|
173
|
+
}
|
|
172
174
|
}
|
|
173
|
-
const fileResult = createFileEntry(filepath, resultCode, mapContent, integrityAlgorithm);
|
|
175
|
+
const fileResult = createFileEntry(filepath, resultCode, mapContent, memoryMode, integrityAlgorithm);
|
|
174
176
|
await cachePut(resultCode, cacheKeys[isOriginal ? 0 /* OriginalCode */ : 2 /* DownlevelCode */], fileResult.integrity);
|
|
175
|
-
|
|
177
|
+
if (!memoryMode) {
|
|
178
|
+
fs.writeFileSync(filepath, resultCode);
|
|
179
|
+
}
|
|
176
180
|
return fileResult;
|
|
177
181
|
}
|
|
178
182
|
async function terserMangle(code, options = {}) {
|
|
@@ -200,16 +204,18 @@ async function terserMangle(code, options = {}) {
|
|
|
200
204
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
201
205
|
return { code: minifyOutput.code, map: minifyOutput.map };
|
|
202
206
|
}
|
|
203
|
-
function createFileEntry(filename, code, map, integrityAlgorithm) {
|
|
207
|
+
function createFileEntry(filename, code, map, memoryMode, integrityAlgorithm) {
|
|
204
208
|
return {
|
|
205
209
|
filename: filename,
|
|
206
210
|
size: Buffer.byteLength(code),
|
|
207
211
|
integrity: integrityAlgorithm && generateIntegrityValue(integrityAlgorithm, code),
|
|
212
|
+
content: memoryMode ? code : undefined,
|
|
208
213
|
map: !map
|
|
209
214
|
? undefined
|
|
210
215
|
: {
|
|
211
216
|
filename: filename + '.map',
|
|
212
217
|
size: Buffer.byteLength(map),
|
|
218
|
+
content: memoryMode ? map : undefined,
|
|
213
219
|
},
|
|
214
220
|
};
|
|
215
221
|
}
|
|
@@ -386,7 +386,7 @@ function getCommonConfig(wco) {
|
|
|
386
386
|
test: /\.[cm]?js$|\.tsx?$/,
|
|
387
387
|
// The below is needed due to a bug in `@babel/runtime`. See: https://github.com/babel/babel/issues/12824
|
|
388
388
|
resolve: { fullySpecified: false },
|
|
389
|
-
exclude: [/[
|
|
389
|
+
exclude: [/[/\\](?:core-js|@babel|tslib|web-animations-js|web-streams-polyfill)[/\\]/],
|
|
390
390
|
use: [
|
|
391
391
|
{
|
|
392
392
|
loader: require.resolve('../../babel/webpack-loader'),
|
|
@@ -61,6 +61,7 @@ function getTestConfig(wco) {
|
|
|
61
61
|
target: wco.tsConfig.options.target === typescript_1.ScriptTarget.ES5 ? ['web', 'es5'] : 'web',
|
|
62
62
|
resolve: {
|
|
63
63
|
mainFields: ['es2015', 'browser', 'module', 'main'],
|
|
64
|
+
conditionNames: ['es2015', '...'],
|
|
64
65
|
},
|
|
65
66
|
devtool: false,
|
|
66
67
|
entry: {
|