@angular-devkit/build-angular 15.1.0-next.1 → 15.1.0-next.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 +11 -11
- package/src/babel/presets/application.d.ts +0 -1
- package/src/babel/presets/application.js +29 -1
- package/src/babel/webpack-loader.js +5 -11
- package/src/builders/browser-esbuild/index.js +51 -13
- package/src/builders/browser-esbuild/javascript-transformer.d.ts +0 -1
- package/src/builders/browser-esbuild/javascript-transformer.js +13 -6
- package/src/builders/browser-esbuild/options.d.ts +1 -1
- package/src/builders/browser-esbuild/options.js +2 -1
- package/src/utils/esbuild-targets.js +17 -2
- package/src/utils/index-file/augment-index-html.js +1 -1
- package/src/utils/index-file/html-rewriting-stream.d.ts +1 -1
- package/src/utils/index-file/html-rewriting-stream.js +24 -20
- package/src/utils/index-file/inline-fonts.js +6 -2
- package/src/webpack/plugins/javascript-optimizer-worker.js +3 -2
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "15.1.0-next.
|
|
3
|
+
"version": "15.1.0-next.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.1501.0-next.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1501.0-next.
|
|
12
|
-
"@angular-devkit/core": "15.1.0-next.
|
|
10
|
+
"@angular-devkit/architect": "0.1501.0-next.2",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1501.0-next.2",
|
|
12
|
+
"@angular-devkit/core": "15.1.0-next.2",
|
|
13
13
|
"@babel/core": "7.20.5",
|
|
14
14
|
"@babel/generator": "7.20.5",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.18.6",
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
"@babel/runtime": "7.20.6",
|
|
21
21
|
"@babel/template": "7.18.10",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.7",
|
|
23
|
-
"@ngtools/webpack": "15.1.0-next.
|
|
23
|
+
"@ngtools/webpack": "15.1.0-next.2",
|
|
24
24
|
"ansi-colors": "4.1.3",
|
|
25
25
|
"autoprefixer": "10.4.13",
|
|
26
26
|
"babel-loader": "9.1.0",
|
|
27
27
|
"babel-plugin-istanbul": "6.1.1",
|
|
28
28
|
"browserslist": "4.21.4",
|
|
29
|
-
"cacache": "17.0.
|
|
29
|
+
"cacache": "17.0.3",
|
|
30
30
|
"chokidar": "3.5.3",
|
|
31
31
|
"copy-webpack-plugin": "11.0.0",
|
|
32
32
|
"critters": "0.0.16",
|
|
33
33
|
"css-loader": "6.7.2",
|
|
34
|
-
"esbuild-wasm": "0.
|
|
34
|
+
"esbuild-wasm": "0.16.2",
|
|
35
35
|
"glob": "8.0.3",
|
|
36
36
|
"https-proxy-agent": "5.0.1",
|
|
37
37
|
"inquirer": "8.2.4",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"less-loader": "11.1.0",
|
|
42
42
|
"license-webpack-plugin": "4.0.2",
|
|
43
43
|
"loader-utils": "3.2.1",
|
|
44
|
-
"magic-string": "0.
|
|
45
|
-
"mini-css-extract-plugin": "2.7.
|
|
44
|
+
"magic-string": "0.27.0",
|
|
45
|
+
"mini-css-extract-plugin": "2.7.2",
|
|
46
46
|
"open": "8.4.0",
|
|
47
47
|
"ora": "5.4.1",
|
|
48
48
|
"parse5-html-rewriting-stream": "6.0.1",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"semver": "7.3.8",
|
|
57
57
|
"source-map-loader": "4.0.1",
|
|
58
58
|
"source-map-support": "0.5.21",
|
|
59
|
-
"terser": "5.16.
|
|
59
|
+
"terser": "5.16.1",
|
|
60
60
|
"text-table": "0.2.0",
|
|
61
61
|
"tree-kill": "1.2.2",
|
|
62
62
|
"tslib": "2.4.1",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"webpack-subresource-integrity": "5.1.0"
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
|
-
"esbuild": "0.
|
|
70
|
+
"esbuild": "0.16.2"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"@angular/compiler-cli": "^15.0.0-next",
|
|
@@ -31,7 +31,6 @@ export interface ApplicationPresetOptions {
|
|
|
31
31
|
jitMode: boolean;
|
|
32
32
|
linkerPluginCreator: typeof import('@angular/compiler-cli/linker/babel').createEs2015LinkerPlugin;
|
|
33
33
|
};
|
|
34
|
-
forcePresetEnv?: boolean;
|
|
35
34
|
forceAsyncTransformation?: boolean;
|
|
36
35
|
instrumentCode?: {
|
|
37
36
|
includedBasePath: string;
|
|
@@ -29,10 +29,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
29
29
|
__setModuleDefault(result, mod);
|
|
30
30
|
return result;
|
|
31
31
|
};
|
|
32
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
+
};
|
|
32
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
36
|
const assert_1 = require("assert");
|
|
37
|
+
const browserslist_1 = __importDefault(require("browserslist"));
|
|
34
38
|
const fs = __importStar(require("fs"));
|
|
35
39
|
const path = __importStar(require("path"));
|
|
40
|
+
/**
|
|
41
|
+
* List of browsers which are affected by a WebKit bug where class field
|
|
42
|
+
* initializers might have incorrect variable scopes.
|
|
43
|
+
*
|
|
44
|
+
* See: https://github.com/angular/angular-cli/issues/24355#issuecomment-1333477033
|
|
45
|
+
* See: https://github.com/WebKit/WebKit/commit/e8788a34b3d5f5b4edd7ff6450b80936bff396f2
|
|
46
|
+
*/
|
|
47
|
+
const safariClassFieldScopeBugBrowsers = new Set((0, browserslist_1.default)([
|
|
48
|
+
// Safari <15 is technically not supported via https://angular.io/guide/browser-support,
|
|
49
|
+
// but we apply the workaround if forcibly selected.
|
|
50
|
+
'Safari <=15',
|
|
51
|
+
'iOS <=15',
|
|
52
|
+
]));
|
|
36
53
|
function createI18nDiagnostics(reporter) {
|
|
37
54
|
const diagnostics = new (class {
|
|
38
55
|
constructor() {
|
|
@@ -113,13 +130,24 @@ function default_1(api, options) {
|
|
|
113
130
|
},
|
|
114
131
|
}));
|
|
115
132
|
}
|
|
116
|
-
|
|
133
|
+
// Applications code ES version can be controlled using TypeScript's `target` option.
|
|
134
|
+
// However, this doesn't effect libraries and hence we use preset-env to downlevel ES features
|
|
135
|
+
// based on the supported browsers in browserslist.
|
|
136
|
+
if (options.supportedBrowsers) {
|
|
137
|
+
const includePlugins = [];
|
|
138
|
+
// If a Safari browser affected by the class field scope bug is selected, we
|
|
139
|
+
// downlevel class properties by ensuring the class properties Babel plugin
|
|
140
|
+
// is always included- regardless of the preset-env targets.
|
|
141
|
+
if (options.supportedBrowsers.some((b) => safariClassFieldScopeBugBrowsers.has(b))) {
|
|
142
|
+
includePlugins.push('@babel/plugin-proposal-class-properties');
|
|
143
|
+
}
|
|
117
144
|
presets.push([
|
|
118
145
|
require('@babel/preset-env').default,
|
|
119
146
|
{
|
|
120
147
|
bugfixes: true,
|
|
121
148
|
modules: false,
|
|
122
149
|
targets: options.supportedBrowsers,
|
|
150
|
+
include: includePlugins,
|
|
123
151
|
exclude: ['transform-typeof-symbol'],
|
|
124
152
|
},
|
|
125
153
|
]);
|
|
@@ -51,13 +51,12 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
51
51
|
});
|
|
52
52
|
return {
|
|
53
53
|
async customOptions(options, { source, map }) {
|
|
54
|
-
var _a, _b
|
|
54
|
+
var _a, _b;
|
|
55
55
|
const { i18n, aot, optimize, instrumentCode, supportedBrowsers, ...rawOptions } = options;
|
|
56
56
|
// Must process file if plugins are added
|
|
57
57
|
let shouldProcess = Array.isArray(rawOptions.plugins) && rawOptions.plugins.length > 0;
|
|
58
58
|
const customOptions = {
|
|
59
59
|
forceAsyncTransformation: false,
|
|
60
|
-
forcePresetEnv: false,
|
|
61
60
|
angularLinker: undefined,
|
|
62
61
|
i18n: undefined,
|
|
63
62
|
instrumentCode: undefined,
|
|
@@ -76,20 +75,15 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
76
75
|
};
|
|
77
76
|
shouldProcess = true;
|
|
78
77
|
}
|
|
79
|
-
// Analyze for ES target processing
|
|
80
|
-
if ((_a = customOptions.supportedBrowsers) === null || _a === void 0 ? void 0 : _a.length) {
|
|
81
|
-
// Applications code ES version can be controlled using TypeScript's `target` option.
|
|
82
|
-
// However, this doesn't effect libraries and hence we use preset-env to downlevel ES fetaures
|
|
83
|
-
// based on the supported browsers in browserlist.
|
|
84
|
-
customOptions.forcePresetEnv = true;
|
|
85
|
-
}
|
|
86
78
|
// Application code (TS files) will only contain native async if target is ES2017+.
|
|
87
79
|
// However, third-party libraries can regardless of the target option.
|
|
88
80
|
// APF packages with code in [f]esm2015 directories is downlevelled to ES2015 and
|
|
89
81
|
// will not have native async.
|
|
90
82
|
customOptions.forceAsyncTransformation =
|
|
91
83
|
!/[\\/][_f]?esm2015[\\/]/.test(this.resourcePath) && source.includes('async');
|
|
92
|
-
shouldProcess || (shouldProcess = customOptions.forceAsyncTransformation ||
|
|
84
|
+
shouldProcess || (shouldProcess = customOptions.forceAsyncTransformation ||
|
|
85
|
+
customOptions.supportedBrowsers !== undefined ||
|
|
86
|
+
false);
|
|
93
87
|
// Analyze for i18n inlining
|
|
94
88
|
if (i18n &&
|
|
95
89
|
!/[\\/]@angular[\\/](?:compiler|localize)/.test(this.resourcePath) &&
|
|
@@ -128,7 +122,7 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
128
122
|
pureTopLevel: angularPackage,
|
|
129
123
|
// JavaScript modules that are marked as side effect free are considered to have
|
|
130
124
|
// no decorators that contain non-local effects.
|
|
131
|
-
wrapDecorators: !!((
|
|
125
|
+
wrapDecorators: !!((_b = (_a = this._module) === null || _a === void 0 ? void 0 : _a.factoryMeta) === null || _b === void 0 ? void 0 : _b.sideEffectFree),
|
|
132
126
|
};
|
|
133
127
|
shouldProcess = true;
|
|
134
128
|
}
|
|
@@ -190,19 +190,7 @@ function createCodeBundleOptions(options, target, sourceFileCache) {
|
|
|
190
190
|
entryNames: outputNames.bundles,
|
|
191
191
|
assetNames: outputNames.media,
|
|
192
192
|
target,
|
|
193
|
-
supported:
|
|
194
|
-
// Native async/await is not supported with Zone.js. Disabling support here will cause
|
|
195
|
-
// esbuild to downlevel async/await and for await...of to a Zone.js supported form. However, esbuild
|
|
196
|
-
// does not currently support downleveling async generators. Instead babel is used within the JS/TS
|
|
197
|
-
// loader to perform the downlevel transformation.
|
|
198
|
-
// NOTE: If esbuild adds support in the future, the babel support for async generators can be disabled.
|
|
199
|
-
'async-await': false,
|
|
200
|
-
// V8 currently has a performance defect involving object spread operations that can cause signficant
|
|
201
|
-
// degradation in runtime performance. By not supporting the language feature here, a downlevel form
|
|
202
|
-
// will be used instead which provides a workaround for the performance issue.
|
|
203
|
-
// For more details: https://bugs.chromium.org/p/v8/issues/detail?id=11536
|
|
204
|
-
'object-rest-spread': false,
|
|
205
|
-
},
|
|
193
|
+
supported: getFeatureSupport(target),
|
|
206
194
|
mainFields: ['es2020', 'browser', 'module', 'main'],
|
|
207
195
|
conditions: ['es2020', 'es2015', 'module'],
|
|
208
196
|
resolveExtensions: ['.ts', '.tsx', '.mjs', '.js'],
|
|
@@ -249,6 +237,56 @@ function createCodeBundleOptions(options, target, sourceFileCache) {
|
|
|
249
237
|
},
|
|
250
238
|
};
|
|
251
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* Generates a syntax feature object map for Angular applications based on a list of targets.
|
|
242
|
+
* A full set of feature names can be found here: https://esbuild.github.io/api/#supported
|
|
243
|
+
* @param target An array of browser/engine targets in the format accepted by the esbuild `target` option.
|
|
244
|
+
* @returns An object that can be used with the esbuild build `supported` option.
|
|
245
|
+
*/
|
|
246
|
+
function getFeatureSupport(target) {
|
|
247
|
+
const supported = {
|
|
248
|
+
// Native async/await is not supported with Zone.js. Disabling support here will cause
|
|
249
|
+
// esbuild to downlevel async/await and for await...of to a Zone.js supported form. However, esbuild
|
|
250
|
+
// does not currently support downleveling async generators. Instead babel is used within the JS/TS
|
|
251
|
+
// loader to perform the downlevel transformation.
|
|
252
|
+
// NOTE: If esbuild adds support in the future, the babel support for async generators can be disabled.
|
|
253
|
+
'async-await': false,
|
|
254
|
+
// V8 currently has a performance defect involving object spread operations that can cause signficant
|
|
255
|
+
// degradation in runtime performance. By not supporting the language feature here, a downlevel form
|
|
256
|
+
// will be used instead which provides a workaround for the performance issue.
|
|
257
|
+
// For more details: https://bugs.chromium.org/p/v8/issues/detail?id=11536
|
|
258
|
+
'object-rest-spread': false,
|
|
259
|
+
};
|
|
260
|
+
// Detect Safari browser versions that have a class field behavior bug
|
|
261
|
+
// See: https://github.com/angular/angular-cli/issues/24355#issuecomment-1333477033
|
|
262
|
+
// See: https://github.com/WebKit/WebKit/commit/e8788a34b3d5f5b4edd7ff6450b80936bff396f2
|
|
263
|
+
let safariClassFieldScopeBug = false;
|
|
264
|
+
for (const browser of target) {
|
|
265
|
+
let majorVersion;
|
|
266
|
+
if (browser.startsWith('ios')) {
|
|
267
|
+
majorVersion = Number(browser.slice(3, 5));
|
|
268
|
+
}
|
|
269
|
+
else if (browser.startsWith('safari')) {
|
|
270
|
+
majorVersion = Number(browser.slice(6, 8));
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
// Technically, 14.0 is not broken but rather does not have support. However, the behavior
|
|
276
|
+
// is identical since it would be set to false by esbuild if present as a target.
|
|
277
|
+
if (majorVersion === 14 || majorVersion === 15) {
|
|
278
|
+
safariClassFieldScopeBug = true;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
// If class field support cannot be used set to false; otherwise leave undefined to allow
|
|
283
|
+
// esbuild to use `target` to determine support.
|
|
284
|
+
if (safariClassFieldScopeBug) {
|
|
285
|
+
supported['class-field'] = false;
|
|
286
|
+
supported['class-static-field'] = false;
|
|
287
|
+
}
|
|
288
|
+
return supported;
|
|
289
|
+
}
|
|
252
290
|
function createGlobalStylesBundleOptions(options, target) {
|
|
253
291
|
const { workspaceRoot, optimizationOptions, sourcemapOptions, outputNames, globalStyles, preserveSymlinks, externalDependencies, stylePreprocessorOptions, watch, } = options;
|
|
254
292
|
const buildOptions = (0, stylesheets_1.createStylesheetBundleOptions)({
|
|
@@ -22,7 +22,6 @@ export interface JavaScriptTransformerOptions {
|
|
|
22
22
|
*/
|
|
23
23
|
export declare class JavaScriptTransformer {
|
|
24
24
|
#private;
|
|
25
|
-
private options;
|
|
26
25
|
constructor(options: JavaScriptTransformerOptions, maxThreads?: number);
|
|
27
26
|
/**
|
|
28
27
|
* Performs JavaScript transformations on a file from the filesystem.
|
|
@@ -20,7 +20,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
20
20
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
21
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
22
|
};
|
|
23
|
-
var _JavaScriptTransformer_workerPool;
|
|
23
|
+
var _JavaScriptTransformer_workerPool, _JavaScriptTransformer_commonOptions;
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.JavaScriptTransformer = void 0;
|
|
26
26
|
const piscina_1 = __importDefault(require("piscina"));
|
|
@@ -33,12 +33,19 @@ const piscina_1 = __importDefault(require("piscina"));
|
|
|
33
33
|
*/
|
|
34
34
|
class JavaScriptTransformer {
|
|
35
35
|
constructor(options, maxThreads) {
|
|
36
|
-
this.options = options;
|
|
37
36
|
_JavaScriptTransformer_workerPool.set(this, void 0);
|
|
37
|
+
_JavaScriptTransformer_commonOptions.set(this, void 0);
|
|
38
38
|
__classPrivateFieldSet(this, _JavaScriptTransformer_workerPool, new piscina_1.default({
|
|
39
39
|
filename: require.resolve('./javascript-transformer-worker'),
|
|
40
40
|
maxThreads,
|
|
41
41
|
}), "f");
|
|
42
|
+
// Extract options to ensure only the named options are serialized and sent to the worker
|
|
43
|
+
const { sourcemap, thirdPartySourcemaps = false, advancedOptimizations = false } = options;
|
|
44
|
+
__classPrivateFieldSet(this, _JavaScriptTransformer_commonOptions, {
|
|
45
|
+
sourcemap,
|
|
46
|
+
thirdPartySourcemaps,
|
|
47
|
+
advancedOptimizations,
|
|
48
|
+
}, "f");
|
|
42
49
|
}
|
|
43
50
|
/**
|
|
44
51
|
* Performs JavaScript transformations on a file from the filesystem.
|
|
@@ -51,7 +58,7 @@ class JavaScriptTransformer {
|
|
|
51
58
|
// they may need linking. The data is also not yet available to perform most transformation checks.
|
|
52
59
|
return __classPrivateFieldGet(this, _JavaScriptTransformer_workerPool, "f").run({
|
|
53
60
|
filename,
|
|
54
|
-
...this
|
|
61
|
+
...__classPrivateFieldGet(this, _JavaScriptTransformer_commonOptions, "f"),
|
|
55
62
|
});
|
|
56
63
|
}
|
|
57
64
|
/**
|
|
@@ -66,7 +73,7 @@ class JavaScriptTransformer {
|
|
|
66
73
|
// Perform a quick test to determine if the data needs any transformations.
|
|
67
74
|
// This allows directly returning the data without the worker communication overhead.
|
|
68
75
|
let forceAsyncTransformation;
|
|
69
|
-
if (skipLinker && !this.
|
|
76
|
+
if (skipLinker && !__classPrivateFieldGet(this, _JavaScriptTransformer_commonOptions, "f").advancedOptimizations) {
|
|
70
77
|
// If the linker is being skipped and no optimizations are needed, only async transformation is left.
|
|
71
78
|
// This checks for async generator functions. All other async transformation is handled by esbuild.
|
|
72
79
|
forceAsyncTransformation = data.includes('async') && /async\s+function\s*\*/.test(data);
|
|
@@ -80,7 +87,7 @@ class JavaScriptTransformer {
|
|
|
80
87
|
// Send the async check result if present to avoid rechecking in the worker
|
|
81
88
|
forceAsyncTransformation,
|
|
82
89
|
skipLinker,
|
|
83
|
-
...this
|
|
90
|
+
...__classPrivateFieldGet(this, _JavaScriptTransformer_commonOptions, "f"),
|
|
84
91
|
});
|
|
85
92
|
}
|
|
86
93
|
/**
|
|
@@ -92,4 +99,4 @@ class JavaScriptTransformer {
|
|
|
92
99
|
}
|
|
93
100
|
}
|
|
94
101
|
exports.JavaScriptTransformer = JavaScriptTransformer;
|
|
95
|
-
_JavaScriptTransformer_workerPool = new WeakMap();
|
|
102
|
+
_JavaScriptTransformer_workerPool = new WeakMap(), _JavaScriptTransformer_commonOptions = new WeakMap();
|
|
@@ -25,7 +25,7 @@ export declare function normalizeOptions(context: BuilderContext, projectName: s
|
|
|
25
25
|
crossOrigin: import("./schema").CrossOrigin | undefined;
|
|
26
26
|
externalDependencies: string[] | undefined;
|
|
27
27
|
poll: number | undefined;
|
|
28
|
-
preserveSymlinks: boolean
|
|
28
|
+
preserveSymlinks: boolean;
|
|
29
29
|
stylePreprocessorOptions: import("./schema").StylePreprocessorOptions | undefined;
|
|
30
30
|
subresourceIntegrity: boolean | undefined;
|
|
31
31
|
verbose: boolean | undefined;
|
|
@@ -131,7 +131,8 @@ async function normalizeOptions(context, projectName, options) {
|
|
|
131
131
|
crossOrigin,
|
|
132
132
|
externalDependencies,
|
|
133
133
|
poll,
|
|
134
|
-
|
|
134
|
+
// If not explicitly set, default to the Node.js process argument
|
|
135
|
+
preserveSymlinks: preserveSymlinks !== null && preserveSymlinks !== void 0 ? preserveSymlinks : process.execArgv.includes('--preserve-symlinks'),
|
|
135
136
|
stylePreprocessorOptions,
|
|
136
137
|
subresourceIntegrity,
|
|
137
138
|
verbose,
|
|
@@ -15,9 +15,18 @@ exports.transformSupportedBrowsersToTargets = void 0;
|
|
|
15
15
|
function transformSupportedBrowsersToTargets(supportedBrowsers) {
|
|
16
16
|
const transformed = [];
|
|
17
17
|
// https://esbuild.github.io/api/#target
|
|
18
|
-
const esBuildSupportedBrowsers = new Set([
|
|
18
|
+
const esBuildSupportedBrowsers = new Set([
|
|
19
|
+
'chrome',
|
|
20
|
+
'edge',
|
|
21
|
+
'firefox',
|
|
22
|
+
'ie',
|
|
23
|
+
'ios',
|
|
24
|
+
'node',
|
|
25
|
+
'opera',
|
|
26
|
+
'safari',
|
|
27
|
+
]);
|
|
19
28
|
for (const browser of supportedBrowsers) {
|
|
20
|
-
let [browserName, version] = browser.split(' ');
|
|
29
|
+
let [browserName, version] = browser.toLowerCase().split(' ');
|
|
21
30
|
// browserslist uses the name `ios_saf` for iOS Safari whereas esbuild uses `ios`
|
|
22
31
|
if (browserName === 'ios_saf') {
|
|
23
32
|
browserName = 'ios';
|
|
@@ -31,6 +40,12 @@ function transformSupportedBrowsersToTargets(supportedBrowsers) {
|
|
|
31
40
|
// a Technology Preview (TP) of Safari is assumed to support all currently known features.
|
|
32
41
|
version = '999';
|
|
33
42
|
}
|
|
43
|
+
else if (!version.includes('.')) {
|
|
44
|
+
// A lone major version is considered by esbuild to include all minor versions. However,
|
|
45
|
+
// browserslist does not and is also inconsistent in its `.0` version naming. For example,
|
|
46
|
+
// Safari 15.0 is named `safari 15` but Safari 16.0 is named `safari 16.0`.
|
|
47
|
+
version += '.0';
|
|
48
|
+
}
|
|
34
49
|
transformed.push(browserName + version);
|
|
35
50
|
}
|
|
36
51
|
}
|
|
@@ -125,7 +125,7 @@ async function augmentIndexHtml(params) {
|
|
|
125
125
|
}
|
|
126
126
|
rewriter.emitEndTag(tag);
|
|
127
127
|
});
|
|
128
|
-
const content = await transformedContent;
|
|
128
|
+
const content = await transformedContent();
|
|
129
129
|
return {
|
|
130
130
|
content: linkTags.length || scriptTags.length
|
|
131
131
|
? // In case no body/head tags are not present (dotnet partial templates)
|
|
@@ -37,26 +37,30 @@ async function htmlRewritingStream(content) {
|
|
|
37
37
|
const rewriter = new (await Promise.resolve().then(() => __importStar(require('parse5-html-rewriting-stream')))).default();
|
|
38
38
|
return {
|
|
39
39
|
rewriter,
|
|
40
|
-
transformedContent:
|
|
41
|
-
new
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
40
|
+
transformedContent: () => {
|
|
41
|
+
return new Promise((resolve) => {
|
|
42
|
+
new stream_1.Readable({
|
|
43
|
+
encoding: 'utf8',
|
|
44
|
+
read() {
|
|
45
|
+
this.push(Buffer.from(content));
|
|
46
|
+
this.push(null);
|
|
47
|
+
},
|
|
48
|
+
})
|
|
49
|
+
.pipe(rewriter)
|
|
50
|
+
.pipe(new stream_1.Writable({
|
|
51
|
+
write(chunk, encoding, callback) {
|
|
52
|
+
chunks.push(typeof chunk === 'string'
|
|
53
|
+
? Buffer.from(chunk, encoding)
|
|
54
|
+
: chunk);
|
|
55
|
+
callback();
|
|
56
|
+
},
|
|
57
|
+
final(callback) {
|
|
58
|
+
callback();
|
|
59
|
+
resolve(Buffer.concat(chunks).toString());
|
|
60
|
+
},
|
|
61
|
+
}));
|
|
62
|
+
});
|
|
63
|
+
},
|
|
60
64
|
};
|
|
61
65
|
}
|
|
62
66
|
exports.htmlRewritingStream = htmlRewritingStream;
|
|
@@ -63,7 +63,7 @@ class InlineFontsProcessor {
|
|
|
63
63
|
const hrefList = [];
|
|
64
64
|
const existingPreconnect = new Set();
|
|
65
65
|
// Collector link tags with href
|
|
66
|
-
const { rewriter: collectorStream } = await (0, html_rewriting_stream_1.htmlRewritingStream)(content);
|
|
66
|
+
const { rewriter: collectorStream, transformedContent: initCollectorStream } = await (0, html_rewriting_stream_1.htmlRewritingStream)(content);
|
|
67
67
|
collectorStream.on('startTag', (tag) => {
|
|
68
68
|
const { tagName, attrs } = tag;
|
|
69
69
|
if (tagName !== 'link') {
|
|
@@ -95,6 +95,10 @@ class InlineFontsProcessor {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
|
+
initCollectorStream().catch(() => {
|
|
99
|
+
// We don't really care about any errors here because it just initializes
|
|
100
|
+
// the rewriting stream, as we are waiting for `finish` below.
|
|
101
|
+
});
|
|
98
102
|
await new Promise((resolve) => collectorStream.on('finish', resolve));
|
|
99
103
|
// Download stylesheets
|
|
100
104
|
const hrefsContent = new Map();
|
|
@@ -146,7 +150,7 @@ class InlineFontsProcessor {
|
|
|
146
150
|
break;
|
|
147
151
|
}
|
|
148
152
|
});
|
|
149
|
-
return transformedContent;
|
|
153
|
+
return transformedContent();
|
|
150
154
|
}
|
|
151
155
|
async getResponse(url) {
|
|
152
156
|
var _a;
|
|
@@ -90,8 +90,9 @@ async function optimizeWithTerser(name, code, sourcemaps, advanced) {
|
|
|
90
90
|
passes: advanced ? 2 : 1,
|
|
91
91
|
pure_getters: advanced,
|
|
92
92
|
},
|
|
93
|
-
//
|
|
94
|
-
|
|
93
|
+
// Set to ES2015 to prevent higher level features from being introduced when browserslist
|
|
94
|
+
// contains older browsers. The build system requires browsers to support ES2015 at a minimum.
|
|
95
|
+
ecma: 2015,
|
|
95
96
|
// esbuild in the first pass is used to minify identifiers instead of mangle here
|
|
96
97
|
mangle: false,
|
|
97
98
|
// esbuild in the first pass is used to minify function names
|