@angular-devkit/build-angular 0.803.19 → 0.803.23
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/angular-cli-files/models/build-options.d.ts +1 -0
- package/src/angular-cli-files/models/webpack-configs/browser.js +1 -1
- package/src/angular-cli-files/models/webpack-configs/test.js +2 -3
- package/src/angular-cli-files/utilities/stats.js +9 -1
- package/src/browser/action-cache.d.ts +1 -1
- package/src/browser/action-cache.js +14 -10
- package/src/browser/index.js +4 -9
- package/src/dev-server/index.js +0 -4
- package/src/utils/process-bundle.d.ts +1 -1
- package/src/utils/process-bundle.js +87 -97
- package/src/utils/webpack-browser-config.js +1 -0
package/package.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "0.803.
|
|
3
|
+
"version": "0.803.23",
|
|
4
4
|
"description": "Angular Webpack Build Facade",
|
|
5
5
|
"experimental": true,
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"typings": "src/index.d.ts",
|
|
8
8
|
"builders": "builders.json",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@angular-devkit/architect": "0.803.
|
|
11
|
-
"@angular-devkit/build-optimizer": "0.803.
|
|
12
|
-
"@angular-devkit/build-webpack": "0.803.
|
|
13
|
-
"@angular-devkit/core": "8.3.
|
|
14
|
-
"@babel/core": "7.
|
|
15
|
-
"@babel/preset-env": "7.
|
|
16
|
-
"@ngtools/webpack": "8.3.
|
|
10
|
+
"@angular-devkit/architect": "0.803.23",
|
|
11
|
+
"@angular-devkit/build-optimizer": "0.803.23",
|
|
12
|
+
"@angular-devkit/build-webpack": "0.803.23",
|
|
13
|
+
"@angular-devkit/core": "8.3.23",
|
|
14
|
+
"@babel/core": "7.7.5",
|
|
15
|
+
"@babel/preset-env": "7.7.6",
|
|
16
|
+
"@ngtools/webpack": "8.3.23",
|
|
17
17
|
"ajv": "6.10.2",
|
|
18
18
|
"autoprefixer": "9.6.1",
|
|
19
|
-
"browserslist": "4.
|
|
19
|
+
"browserslist": "4.8.3",
|
|
20
20
|
"cacache": "12.0.2",
|
|
21
|
-
"caniuse-lite": "1.0.
|
|
21
|
+
"caniuse-lite": "1.0.30001019",
|
|
22
22
|
"circular-dependency-plugin": "5.2.0",
|
|
23
23
|
"clean-css": "4.2.1",
|
|
24
|
-
"
|
|
24
|
+
"coverage-istanbul-loader": "2.0.3",
|
|
25
|
+
"copy-webpack-plugin": "5.1.1",
|
|
25
26
|
"core-js": "3.2.1",
|
|
26
27
|
"file-loader": "4.2.0",
|
|
27
28
|
"find-cache-dir": "3.0.0",
|
|
28
29
|
"glob": "7.1.4",
|
|
29
|
-
"istanbul-instrumenter-loader": "3.0.1",
|
|
30
30
|
"jest-worker": "24.9.0",
|
|
31
31
|
"karma-source-map-support": "1.4.0",
|
|
32
32
|
"less": "3.9.0",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"style-loader": "1.0.0",
|
|
54
54
|
"stylus": "0.54.5",
|
|
55
55
|
"stylus-loader": "3.0.2",
|
|
56
|
-
"tree-kill": "1.2.
|
|
56
|
+
"tree-kill": "1.2.2",
|
|
57
57
|
"terser": "4.3.9",
|
|
58
|
-
"terser-webpack-plugin": "1.4.
|
|
58
|
+
"terser-webpack-plugin": "1.4.3",
|
|
59
59
|
"webpack": "4.39.2",
|
|
60
60
|
"webpack-dev-middleware": "3.7.2",
|
|
61
61
|
"webpack-dev-server": "3.9.0",
|
|
@@ -40,7 +40,7 @@ function getBrowserConfig(wco) {
|
|
|
40
40
|
}));
|
|
41
41
|
}
|
|
42
42
|
if (!isEval && (scriptsSourceMap || stylesSourceMap)) {
|
|
43
|
-
extraPlugins.push(utils_1.getSourceMapDevTool(!!scriptsSourceMap, !!stylesSourceMap, hiddenSourceMap));
|
|
43
|
+
extraPlugins.push(utils_1.getSourceMapDevTool(!!scriptsSourceMap, !!stylesSourceMap, wco.differentialLoadingMode ? true : hiddenSourceMap));
|
|
44
44
|
}
|
|
45
45
|
const globalStylesBundleNames = utils_1.normalizeExtraEntryPoints(buildOptions.styles, 'styles')
|
|
46
46
|
.map(style => style.bundleName);
|
|
@@ -21,7 +21,6 @@ function getTestConfig(wco) {
|
|
|
21
21
|
const { root, buildOptions, sourceRoot: include } = wco;
|
|
22
22
|
const extraRules = [];
|
|
23
23
|
const extraPlugins = [];
|
|
24
|
-
// if (buildOptions.codeCoverage && CliConfig.fromProject()) {
|
|
25
24
|
if (buildOptions.codeCoverage) {
|
|
26
25
|
const codeCoverageExclude = buildOptions.codeCoverageExclude;
|
|
27
26
|
const exclude = [
|
|
@@ -37,8 +36,8 @@ function getTestConfig(wco) {
|
|
|
37
36
|
});
|
|
38
37
|
}
|
|
39
38
|
extraRules.push({
|
|
40
|
-
test: /\.(
|
|
41
|
-
loader: 'istanbul-
|
|
39
|
+
test: /\.(jsx?|tsx?)$/,
|
|
40
|
+
loader: require.resolve('coverage-istanbul-loader'),
|
|
42
41
|
options: { esModules: true },
|
|
43
42
|
enforce: 'post',
|
|
44
43
|
exclude,
|
|
@@ -66,11 +66,19 @@ function statsToString(json, statsConfig) {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
exports.statsToString = statsToString;
|
|
69
|
+
// TODO(#16193): Don't emit this warning in the first place rather than just suppressing it.
|
|
70
|
+
const ERRONEOUS_WARNINGS = [
|
|
71
|
+
/multiple assets emit different content.*3rdpartylicenses\.txt/i,
|
|
72
|
+
];
|
|
69
73
|
function statsWarningsToString(json, statsConfig) {
|
|
70
74
|
const colors = statsConfig.colors;
|
|
71
75
|
const rs = (x) => colors ? reset(x) : x;
|
|
72
76
|
const y = (x) => colors ? bold(yellow(x)) : x;
|
|
73
|
-
return rs('\n' + json.warnings
|
|
77
|
+
return rs('\n' + json.warnings
|
|
78
|
+
.map((warning) => `${warning}`)
|
|
79
|
+
.filter((warning) => !ERRONEOUS_WARNINGS.some((erroneous) => erroneous.test(warning)))
|
|
80
|
+
.map((warning) => y(`WARNING in ${warning}`))
|
|
81
|
+
.join('\n\n'));
|
|
74
82
|
}
|
|
75
83
|
exports.statsWarningsToString = statsWarningsToString;
|
|
76
84
|
function statsErrorsToString(json, statsConfig) {
|
|
@@ -12,6 +12,6 @@ export declare class BundleActionCache {
|
|
|
12
12
|
static copyEntryContent(entry: CacheEntry | string, dest: fs.PathLike): void;
|
|
13
13
|
generateBaseCacheKey(content: string): string;
|
|
14
14
|
generateCacheKeys(action: ProcessBundleOptions): string[];
|
|
15
|
-
getCacheEntries(cacheKeys: (string |
|
|
15
|
+
getCacheEntries(cacheKeys: (string | undefined)[]): Promise<(CacheEntry | null)[] | false>;
|
|
16
16
|
getCachedBundleResult(action: ProcessBundleOptions): Promise<ProcessBundleResult | null>;
|
|
17
17
|
}
|
|
@@ -56,26 +56,30 @@ class BundleActionCache {
|
|
|
56
56
|
return baseCacheKey;
|
|
57
57
|
}
|
|
58
58
|
generateCacheKeys(action) {
|
|
59
|
-
|
|
60
|
-
// Postfix added to sourcemap cache keys when vendor sourcemaps are present
|
|
59
|
+
// Postfix added to sourcemap cache keys when vendor, hidden sourcemaps are present
|
|
61
60
|
// Allows non-destructive caching of both variants
|
|
62
|
-
const
|
|
61
|
+
const sourceMapVendorPostfix = action.sourceMaps && action.vendorSourceMaps ? '|vendor' : '';
|
|
62
|
+
// sourceMappingURL is added at the very end which causes the code to be the same when sourcemaps are enabled/disabled
|
|
63
|
+
// When using hiddenSourceMaps we can omit the postfix since sourceMappingURL will not be added.
|
|
64
|
+
// When having sourcemaps a hashed file and non hashed file can have the same content. But the sourceMappingURL will differ.
|
|
65
|
+
const sourceMapPostFix = action.sourceMaps && !action.hiddenSourceMaps ? `|sourcemap|${action.filename}` : '';
|
|
66
|
+
const baseCacheKey = this.generateBaseCacheKey(action.code);
|
|
63
67
|
// Determine cache entries required based on build settings
|
|
64
68
|
const cacheKeys = [];
|
|
65
69
|
// If optimizing and the original is not ignored, add original as required
|
|
66
|
-
if (
|
|
67
|
-
cacheKeys[0 /* OriginalCode */] = baseCacheKey + '|orig';
|
|
70
|
+
if (!action.ignoreOriginal) {
|
|
71
|
+
cacheKeys[0 /* OriginalCode */] = baseCacheKey + sourceMapPostFix + '|orig';
|
|
68
72
|
// If sourcemaps are enabled, add original sourcemap as required
|
|
69
73
|
if (action.sourceMaps) {
|
|
70
|
-
cacheKeys[1 /* OriginalMap */] = baseCacheKey +
|
|
74
|
+
cacheKeys[1 /* OriginalMap */] = baseCacheKey + sourceMapVendorPostfix + '|orig-map';
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
// If not only optimizing, add downlevel as required
|
|
74
78
|
if (!action.optimizeOnly) {
|
|
75
|
-
cacheKeys[2 /* DownlevelCode */] = baseCacheKey + '|dl';
|
|
79
|
+
cacheKeys[2 /* DownlevelCode */] = baseCacheKey + sourceMapPostFix + '|dl';
|
|
76
80
|
// If sourcemaps are enabled, add downlevel sourcemap as required
|
|
77
81
|
if (action.sourceMaps) {
|
|
78
|
-
cacheKeys[3 /* DownlevelMap */] = baseCacheKey +
|
|
82
|
+
cacheKeys[3 /* DownlevelMap */] = baseCacheKey + sourceMapVendorPostfix + '|dl-map';
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
return cacheKeys;
|
|
@@ -140,7 +144,7 @@ class BundleActionCache {
|
|
|
140
144
|
cacheEntry = entries[2 /* DownlevelCode */];
|
|
141
145
|
if (cacheEntry) {
|
|
142
146
|
result.downlevel = {
|
|
143
|
-
filename: action.filename.replace(
|
|
147
|
+
filename: action.filename.replace(/\-es20\d{2}/, '-es5'),
|
|
144
148
|
size: cacheEntry.size,
|
|
145
149
|
integrity: cacheEntry.integrity,
|
|
146
150
|
};
|
|
@@ -148,7 +152,7 @@ class BundleActionCache {
|
|
|
148
152
|
cacheEntry = entries[3 /* DownlevelMap */];
|
|
149
153
|
if (cacheEntry) {
|
|
150
154
|
result.downlevel.map = {
|
|
151
|
-
filename: action.filename.replace(
|
|
155
|
+
filename: action.filename.replace(/\-es20\d{2}/, '-es5') + '.map',
|
|
152
156
|
size: cacheEntry.size,
|
|
153
157
|
};
|
|
154
158
|
BundleActionCache.copyEntryContent(cacheEntry, result.downlevel.filename + '.map');
|
package/src/browser/index.js
CHANGED
|
@@ -212,12 +212,6 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
212
212
|
if (!es5Polyfills) {
|
|
213
213
|
moduleFiles.push(file);
|
|
214
214
|
}
|
|
215
|
-
// If not optimizing then ES2015 polyfills do not need processing
|
|
216
|
-
// Unlike other module scripts, it is never downleveled
|
|
217
|
-
const es2015Polyfills = file.file.startsWith('polyfills-es2015');
|
|
218
|
-
if (!actionOptions.optimize && es2015Polyfills) {
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
215
|
// Retrieve the content/map for the file
|
|
222
216
|
// NOTE: Additional future optimizations will read directly from memory
|
|
223
217
|
let filename = path.resolve(core_1.getSystemPath(root), options.outputPath, file.file);
|
|
@@ -234,8 +228,9 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
234
228
|
}
|
|
235
229
|
if (es5Polyfills) {
|
|
236
230
|
fs.unlinkSync(filename);
|
|
237
|
-
filename = filename.replace(
|
|
231
|
+
filename = filename.replace(/\-es20\d{2}/, '');
|
|
238
232
|
}
|
|
233
|
+
const es2015Polyfills = file.file.startsWith('polyfills-es20');
|
|
239
234
|
// Record the bundle processing action
|
|
240
235
|
// The runtime chunk gets special processing for lazy loaded files
|
|
241
236
|
actions.push({
|
|
@@ -256,8 +251,8 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
256
251
|
}
|
|
257
252
|
// Add the newly created ES5 bundles to the index as nomodule scripts
|
|
258
253
|
const newFilename = es5Polyfills
|
|
259
|
-
? file.file.replace(
|
|
260
|
-
: file.file.replace(
|
|
254
|
+
? file.file.replace(/\-es20\d{2}/, '')
|
|
255
|
+
: file.file.replace(/\-es20\d{2}/, '-es5');
|
|
261
256
|
noModuleFiles.push({ ...file, file: newFilename });
|
|
262
257
|
}
|
|
263
258
|
// Execute the bundle processing actions
|
package/src/dev-server/index.js
CHANGED
|
@@ -323,10 +323,6 @@ function _addLiveReload(options, browserOptions, webpackConfig, clientAddress, l
|
|
|
323
323
|
if (clientAddress.pathname) {
|
|
324
324
|
clientAddress.pathname = path.posix.join(clientAddress.pathname, 'sockjs-node');
|
|
325
325
|
sockjsPath = '&sockPath=' + clientAddress.pathname;
|
|
326
|
-
// ensure webpack-dev-server uses the correct path to connect to the reloading socket
|
|
327
|
-
if (webpackConfig.devServer) {
|
|
328
|
-
webpackConfig.devServer.sockPath = clientAddress.pathname;
|
|
329
|
-
}
|
|
330
326
|
}
|
|
331
327
|
const entryPoints = [`${webpackDevServerPath}?${url.format(clientAddress)}${sockjsPath}`];
|
|
332
328
|
if (options.hmr) {
|
|
@@ -10,7 +10,7 @@ export interface ProcessBundleOptions {
|
|
|
10
10
|
optimize?: boolean;
|
|
11
11
|
optimizeOnly?: boolean;
|
|
12
12
|
ignoreOriginal?: boolean;
|
|
13
|
-
cacheKeys?: (string |
|
|
13
|
+
cacheKeys?: (string | undefined)[];
|
|
14
14
|
integrityAlgorithm?: 'sha256' | 'sha384' | 'sha512';
|
|
15
15
|
runtimeData?: ProcessBundleResult[];
|
|
16
16
|
}
|
|
@@ -7,13 +7,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
* Use of this source code is governed by an MIT-style license that can be
|
|
8
8
|
* found in the LICENSE file at https://angular.io/license
|
|
9
9
|
*/
|
|
10
|
+
const core_1 = require("@babel/core");
|
|
10
11
|
const crypto_1 = require("crypto");
|
|
11
12
|
const fs = require("fs");
|
|
12
13
|
const path = require("path");
|
|
13
14
|
const source_map_1 = require("source-map");
|
|
14
15
|
const terser_1 = require("terser");
|
|
15
|
-
const typescript_1 = require("typescript");
|
|
16
|
-
const webpack_sources_1 = require("webpack-sources");
|
|
17
16
|
const mangle_options_1 = require("./mangle-options");
|
|
18
17
|
const cacache = require('cacache');
|
|
19
18
|
let cachePath;
|
|
@@ -23,7 +22,7 @@ function setup(options) {
|
|
|
23
22
|
exports.setup = setup;
|
|
24
23
|
async function cachePut(content, key, integrity) {
|
|
25
24
|
if (cachePath && key) {
|
|
26
|
-
await cacache.put(cachePath, key, content, {
|
|
25
|
+
await cacache.put(cachePath, key || null, content, {
|
|
27
26
|
metadata: { integrity },
|
|
28
27
|
});
|
|
29
28
|
}
|
|
@@ -43,69 +42,65 @@ async function process(options) {
|
|
|
43
42
|
}
|
|
44
43
|
const basePath = path.dirname(options.filename);
|
|
45
44
|
const filename = path.basename(options.filename);
|
|
46
|
-
const downlevelFilename = filename.replace(
|
|
45
|
+
const downlevelFilename = filename.replace(/\-es20\d{2}/, '-es5');
|
|
47
46
|
const downlevel = !options.optimizeOnly;
|
|
48
47
|
// if code size is larger than 1 MB, manually handle sourcemaps with newer source-map package.
|
|
49
48
|
const codeSize = Buffer.byteLength(options.code);
|
|
50
49
|
const mapSize = options.map ? Buffer.byteLength(options.map) : 0;
|
|
51
|
-
const manualSourceMaps = codeSize >=
|
|
50
|
+
const manualSourceMaps = codeSize >= 500 * 1024 || mapSize >= 500 * 1024;
|
|
52
51
|
const sourceCode = options.code;
|
|
53
|
-
const sourceMap = options.map ? JSON.parse(options.map) :
|
|
52
|
+
const sourceMap = options.map ? JSON.parse(options.map) : false;
|
|
54
53
|
let downlevelCode;
|
|
55
54
|
let downlevelMap;
|
|
56
55
|
if (downlevel) {
|
|
57
56
|
// Downlevel the bundle
|
|
58
|
-
const transformResult =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
const transformResult = await core_1.transformAsync(sourceCode, {
|
|
58
|
+
filename: options.filename,
|
|
59
|
+
// using false ensures that babel will NOT search and process sourcemap comments (large memory usage)
|
|
60
|
+
inputSourceMap: manualSourceMaps ? false : sourceMap,
|
|
61
|
+
babelrc: false,
|
|
62
|
+
presets: [
|
|
63
|
+
[
|
|
64
|
+
require.resolve('@babel/preset-env'),
|
|
65
|
+
{
|
|
66
|
+
// modules aren't needed since the bundles use webpack's custom module loading
|
|
67
|
+
modules: false,
|
|
68
|
+
// 'transform-typeof-symbol' generates slower code
|
|
69
|
+
exclude: ['transform-typeof-symbol'],
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
],
|
|
73
|
+
minified: options.optimize,
|
|
74
|
+
// `false` ensures it is disabled and prevents large file warnings
|
|
75
|
+
compact: options.optimize || false,
|
|
76
|
+
sourceMaps: !!sourceMap,
|
|
64
77
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (manualSourceMaps) {
|
|
68
|
-
downlevelMap = await mergeSourcemaps(sourceMap, JSON.parse(transformResult.sourceMapText));
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
// More accurate but significantly more costly
|
|
72
|
-
const tempSource = new webpack_sources_1.SourceMapSource(transformResult.outputText, downlevelFilename, JSON.parse(transformResult.sourceMapText), sourceCode, sourceMap);
|
|
73
|
-
downlevelMap = tempSource.map();
|
|
74
|
-
}
|
|
78
|
+
if (!transformResult || !transformResult.code) {
|
|
79
|
+
throw new Error(`Unknown error occurred processing bundle for "${options.filename}".`);
|
|
75
80
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const minifyResult = terserMangle(downlevelCode, {
|
|
80
|
-
filename: downlevelFilename,
|
|
81
|
-
map: downlevelMap,
|
|
82
|
-
compress: true,
|
|
83
|
-
});
|
|
84
|
-
downlevelCode = minifyResult.code;
|
|
85
|
-
downlevelMap = minifyResult.map;
|
|
81
|
+
downlevelCode = transformResult.code;
|
|
82
|
+
if (manualSourceMaps && sourceMap && transformResult.map) {
|
|
83
|
+
downlevelMap = await mergeSourcemaps(sourceMap, transformResult.map);
|
|
86
84
|
}
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
else {
|
|
86
|
+
// undefined is needed here to normalize the property type
|
|
87
|
+
downlevelMap = transformResult.map || undefined;
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
90
|
if (downlevelCode) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
await cachePut(mapContent, options.cacheKeys[3 /* DownlevelMap */]);
|
|
100
|
-
fs.writeFileSync(downlevelPath + '.map', mapContent);
|
|
101
|
-
}
|
|
102
|
-
result.downlevel = createFileEntry(downlevelFilename, downlevelCode, mapContent, options.integrityAlgorithm);
|
|
103
|
-
await cachePut(downlevelCode, options.cacheKeys[2 /* DownlevelCode */], result.downlevel.integrity);
|
|
104
|
-
fs.writeFileSync(downlevelPath, downlevelCode);
|
|
91
|
+
result.downlevel = await processBundle({
|
|
92
|
+
...options,
|
|
93
|
+
code: downlevelCode,
|
|
94
|
+
map: downlevelMap,
|
|
95
|
+
filename: path.join(basePath, downlevelFilename),
|
|
96
|
+
isOriginal: false,
|
|
97
|
+
});
|
|
105
98
|
}
|
|
106
|
-
// If original was not processed, add info
|
|
107
99
|
if (!result.original && !options.ignoreOriginal) {
|
|
108
|
-
result.original =
|
|
100
|
+
result.original = await processBundle({
|
|
101
|
+
...options,
|
|
102
|
+
isOriginal: true,
|
|
103
|
+
});
|
|
109
104
|
}
|
|
110
105
|
return result;
|
|
111
106
|
}
|
|
@@ -154,24 +149,40 @@ async function mergeSourcemaps(first, second) {
|
|
|
154
149
|
}
|
|
155
150
|
return map;
|
|
156
151
|
}
|
|
157
|
-
async function
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
152
|
+
async function processBundle(options) {
|
|
153
|
+
const { optimize, isOriginal, code, map, filename: filepath, hiddenSourceMaps, cacheKeys = [], integrityAlgorithm, } = options;
|
|
154
|
+
const rawMap = typeof map === 'string' ? JSON.parse(map) : map;
|
|
155
|
+
const filename = path.basename(filepath);
|
|
156
|
+
let result;
|
|
157
|
+
if (optimize) {
|
|
158
|
+
result = terserMangle(code, {
|
|
159
|
+
filename,
|
|
160
|
+
map: rawMap,
|
|
161
|
+
compress: !isOriginal,
|
|
162
|
+
ecma: isOriginal ? 6 : 5,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
if (rawMap) {
|
|
167
|
+
rawMap.file = filename;
|
|
168
|
+
}
|
|
169
|
+
result = {
|
|
170
|
+
map: rawMap,
|
|
171
|
+
code,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
163
174
|
let mapContent;
|
|
164
175
|
if (result.map) {
|
|
165
|
-
if (!
|
|
166
|
-
result.code += `\n//# sourceMappingURL=${
|
|
176
|
+
if (!hiddenSourceMaps) {
|
|
177
|
+
result.code += `\n//# sourceMappingURL=${filename}.map`;
|
|
167
178
|
}
|
|
168
179
|
mapContent = JSON.stringify(result.map);
|
|
169
|
-
await cachePut(mapContent,
|
|
170
|
-
fs.writeFileSync(
|
|
180
|
+
await cachePut(mapContent, cacheKeys[isOriginal ? 1 /* OriginalMap */ : 3 /* DownlevelMap */]);
|
|
181
|
+
fs.writeFileSync(filepath + '.map', mapContent);
|
|
171
182
|
}
|
|
172
|
-
const fileResult = createFileEntry(
|
|
173
|
-
await cachePut(result.code,
|
|
174
|
-
fs.writeFileSync(
|
|
183
|
+
const fileResult = createFileEntry(filepath, result.code, mapContent, integrityAlgorithm);
|
|
184
|
+
await cachePut(result.code, cacheKeys[isOriginal ? 0 /* OriginalCode */ : 2 /* DownlevelCode */], fileResult.integrity);
|
|
185
|
+
fs.writeFileSync(filepath, result.code);
|
|
175
186
|
return fileResult;
|
|
176
187
|
}
|
|
177
188
|
function terserMangle(code, options = {}) {
|
|
@@ -244,39 +255,18 @@ async function processRuntime(options) {
|
|
|
244
255
|
}
|
|
245
256
|
// Adjust lazy loaded scripts to point to the proper variant
|
|
246
257
|
// Extra spacing is intentional to align source line positions
|
|
247
|
-
downlevelCode = downlevelCode.replace(
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
if (options.map) {
|
|
265
|
-
const rawMap = JSON.parse(options.map);
|
|
266
|
-
rawMap.file = path.basename(downlevelFilePath);
|
|
267
|
-
downlevelMap = JSON.stringify(rawMap);
|
|
268
|
-
}
|
|
269
|
-
result = {
|
|
270
|
-
original: createFileEntry(options.filename, originalCode, options.map, options.integrityAlgorithm),
|
|
271
|
-
downlevel: createFileEntry(downlevelFilePath, downlevelCode, downlevelMap, options.integrityAlgorithm),
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
if (downlevelMap) {
|
|
275
|
-
await cachePut(downlevelMap, (options.cacheKeys && options.cacheKeys[3 /* DownlevelMap */]) || null);
|
|
276
|
-
fs.writeFileSync(downlevelFilePath + '.map', downlevelMap);
|
|
277
|
-
downlevelCode += `\n//# sourceMappingURL=${path.basename(downlevelFilePath)}.map`;
|
|
278
|
-
}
|
|
279
|
-
await cachePut(downlevelCode, (options.cacheKeys && options.cacheKeys[2 /* DownlevelCode */]) || null);
|
|
280
|
-
fs.writeFileSync(downlevelFilePath, downlevelCode);
|
|
281
|
-
return result;
|
|
258
|
+
downlevelCode = downlevelCode.replace(/"\-es20\d{2}\./, ' "-es5.');
|
|
259
|
+
return {
|
|
260
|
+
original: await processBundle({
|
|
261
|
+
...options,
|
|
262
|
+
code: originalCode,
|
|
263
|
+
isOriginal: true,
|
|
264
|
+
}),
|
|
265
|
+
downlevel: await processBundle({
|
|
266
|
+
...options,
|
|
267
|
+
code: downlevelCode,
|
|
268
|
+
filename: options.filename.replace(/\-es20\d{2}/, '-es5'),
|
|
269
|
+
isOriginal: false,
|
|
270
|
+
}),
|
|
271
|
+
};
|
|
282
272
|
}
|
|
@@ -63,6 +63,7 @@ async function generateWebpackConfig(context, workspaceRoot, projectRoot, source
|
|
|
63
63
|
tsConfig,
|
|
64
64
|
tsConfigPath,
|
|
65
65
|
supportES2015,
|
|
66
|
+
differentialLoadingMode: differentialLoading && !utils_1.fullDifferential,
|
|
66
67
|
};
|
|
67
68
|
wco.buildOptions.progress = utils_1.defaultProgress(wco.buildOptions.progress);
|
|
68
69
|
const partials = webpackPartialGenerator(wco);
|