@angular-devkit/build-angular 15.0.0-next.3 → 15.0.0-next.4
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 -11
- package/src/builders/browser-esbuild/compiler-plugin.d.ts +9 -2
- package/src/builders/browser-esbuild/compiler-plugin.js +114 -90
- package/src/builders/browser-esbuild/esbuild.d.ts +4 -3
- package/src/builders/browser-esbuild/esbuild.js +12 -6
- package/src/builders/browser-esbuild/experimental-warnings.js +0 -3
- package/src/builders/browser-esbuild/index.d.ts +3 -3
- package/src/builders/browser-esbuild/index.js +143 -86
- package/src/builders/browser-esbuild/options.d.ts +26 -4
- package/src/builders/browser-esbuild/options.js +56 -5
- package/src/builders/browser-esbuild/watcher.d.ts +23 -0
- package/src/builders/browser-esbuild/watcher.js +93 -0
- package/src/builders/karma/index.d.ts +1 -1
- package/src/builders/karma/index.js +50 -9
- package/src/builders/karma/schema.d.ts +1 -1
- package/src/builders/karma/schema.json +1 -1
- package/src/utils/process-bundle.js +1 -1
- package/src/utils/service-worker.d.ts +3 -0
- package/src/utils/service-worker.js +29 -2
- package/src/webpack/configs/common.js +2 -2
- package/src/webpack/configs/styles.d.ts +1 -7
- package/src/webpack/configs/styles.js +53 -60
- package/src/webpack/plugins/scripts-webpack-plugin.js +24 -5
- package/src/webpack/plugins/styles-webpack-plugin.d.ts +19 -0
- package/src/webpack/plugins/styles-webpack-plugin.js +71 -0
- package/src/webpack/utils/helpers.d.ts +5 -1
- package/src/webpack/utils/helpers.js +24 -14
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "15.0.0-next.
|
|
3
|
+
"version": "15.0.0-next.4",
|
|
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.1500.0-next.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1500.0-next.
|
|
12
|
-
"@angular-devkit/core": "15.0.0-next.
|
|
10
|
+
"@angular-devkit/architect": "0.1500.0-next.4",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1500.0-next.4",
|
|
12
|
+
"@angular-devkit/core": "15.0.0-next.4",
|
|
13
13
|
"@babel/core": "7.19.3",
|
|
14
14
|
"@babel/generator": "7.19.3",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.18.6",
|
|
@@ -20,17 +20,18 @@
|
|
|
20
20
|
"@babel/runtime": "7.19.0",
|
|
21
21
|
"@babel/template": "7.18.10",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.7",
|
|
23
|
-
"@ngtools/webpack": "15.0.0-next.
|
|
23
|
+
"@ngtools/webpack": "15.0.0-next.4",
|
|
24
24
|
"ansi-colors": "4.1.3",
|
|
25
25
|
"autoprefixer": "10.4.12",
|
|
26
26
|
"babel-loader": "8.2.5",
|
|
27
27
|
"babel-plugin-istanbul": "6.1.1",
|
|
28
28
|
"browserslist": "^4.9.1",
|
|
29
29
|
"cacache": "16.1.3",
|
|
30
|
+
"chokidar": "3.5.3",
|
|
30
31
|
"copy-webpack-plugin": "11.0.0",
|
|
31
32
|
"critters": "0.0.16",
|
|
32
33
|
"css-loader": "6.7.1",
|
|
33
|
-
"esbuild-wasm": "0.15.
|
|
34
|
+
"esbuild-wasm": "0.15.10",
|
|
34
35
|
"glob": "8.0.3",
|
|
35
36
|
"https-proxy-agent": "5.0.1",
|
|
36
37
|
"inquirer": "8.2.4",
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
"ora": "5.4.1",
|
|
47
48
|
"parse5-html-rewriting-stream": "6.0.1",
|
|
48
49
|
"piscina": "3.2.0",
|
|
49
|
-
"postcss": "8.4.
|
|
50
|
+
"postcss": "8.4.17",
|
|
50
51
|
"postcss-import": "15.0.0",
|
|
51
52
|
"postcss-loader": "7.0.1",
|
|
52
53
|
"regenerator-runtime": "0.13.9",
|
|
@@ -54,10 +55,10 @@
|
|
|
54
55
|
"rxjs": "6.6.7",
|
|
55
56
|
"sass": "1.55.0",
|
|
56
57
|
"sass-loader": "13.0.2",
|
|
57
|
-
"semver": "7.3.
|
|
58
|
+
"semver": "7.3.8",
|
|
58
59
|
"source-map-loader": "4.0.0",
|
|
59
60
|
"source-map-support": "0.5.21",
|
|
60
|
-
"terser": "5.15.
|
|
61
|
+
"terser": "5.15.1",
|
|
61
62
|
"text-table": "0.2.0",
|
|
62
63
|
"tree-kill": "1.2.2",
|
|
63
64
|
"tslib": "2.4.0",
|
|
@@ -68,7 +69,7 @@
|
|
|
68
69
|
"webpack-subresource-integrity": "5.1.0"
|
|
69
70
|
},
|
|
70
71
|
"optionalDependencies": {
|
|
71
|
-
"esbuild": "0.15.
|
|
72
|
+
"esbuild": "0.15.10"
|
|
72
73
|
},
|
|
73
74
|
"peerDependencies": {
|
|
74
75
|
"@angular/compiler-cli": "^15.0.0-next",
|
|
@@ -112,7 +113,7 @@
|
|
|
112
113
|
"url": "https://github.com/angular/angular-cli.git"
|
|
113
114
|
},
|
|
114
115
|
"engines": {
|
|
115
|
-
"node": "^14.
|
|
116
|
+
"node": "^14.20.0 || >=16.10.0",
|
|
116
117
|
"npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
|
|
117
118
|
"yarn": ">= 1.13.0"
|
|
118
119
|
},
|
|
@@ -6,11 +6,18 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import type { Plugin } from 'esbuild';
|
|
9
|
+
import ts from 'typescript';
|
|
9
10
|
import { BundleStylesheetOptions } from './stylesheets';
|
|
10
|
-
export declare
|
|
11
|
+
export declare class SourceFileCache extends Map<string, ts.SourceFile> {
|
|
12
|
+
readonly modifiedFiles: Set<string>;
|
|
13
|
+
invalidate(files: Iterable<string>): void;
|
|
14
|
+
}
|
|
15
|
+
export interface CompilerPluginOptions {
|
|
11
16
|
sourcemap: boolean;
|
|
12
17
|
tsconfig: string;
|
|
13
18
|
advancedOptimizations?: boolean;
|
|
14
19
|
thirdPartySourcemaps?: boolean;
|
|
15
20
|
fileReplacements?: Record<string, string>;
|
|
16
|
-
|
|
21
|
+
sourceFileCache?: SourceFileCache;
|
|
22
|
+
}
|
|
23
|
+
export declare function createCompilerPlugin(pluginOptions: CompilerPluginOptions, styleOptions: BundleStylesheetOptions): Plugin;
|
|
@@ -33,10 +33,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
33
33
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
34
|
};
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.createCompilerPlugin = void 0;
|
|
36
|
+
exports.createCompilerPlugin = exports.SourceFileCache = void 0;
|
|
37
37
|
const core_1 = require("@babel/core");
|
|
38
38
|
const assert = __importStar(require("assert"));
|
|
39
39
|
const fs_1 = require("fs");
|
|
40
|
+
const os_1 = require("os");
|
|
40
41
|
const path = __importStar(require("path"));
|
|
41
42
|
const typescript_1 = __importDefault(require("typescript"));
|
|
42
43
|
const application_1 = __importDefault(require("../../babel/presets/application"));
|
|
@@ -47,7 +48,7 @@ const stylesheets_1 = require("./stylesheets");
|
|
|
47
48
|
* Converts TypeScript Diagnostic related information into an esbuild compatible note object.
|
|
48
49
|
* Related information is a subset of a full TypeScript Diagnostic and also used for diagnostic
|
|
49
50
|
* notes associated with the main Diagnostic.
|
|
50
|
-
* @param
|
|
51
|
+
* @param info The TypeScript diagnostic relative information to convert.
|
|
51
52
|
* @param host A TypeScript FormatDiagnosticsHost instance to use during conversion.
|
|
52
53
|
* @returns An esbuild diagnostic message as a PartialMessage object
|
|
53
54
|
*/
|
|
@@ -106,6 +107,26 @@ function convertTypeScriptDiagnostic(diagnostic, host) {
|
|
|
106
107
|
}
|
|
107
108
|
return message;
|
|
108
109
|
}
|
|
110
|
+
const USING_WINDOWS = (0, os_1.platform)() === 'win32';
|
|
111
|
+
const WINDOWS_SEP_REGEXP = new RegExp(`\\${path.win32.sep}`, 'g');
|
|
112
|
+
class SourceFileCache extends Map {
|
|
113
|
+
constructor() {
|
|
114
|
+
super(...arguments);
|
|
115
|
+
this.modifiedFiles = new Set();
|
|
116
|
+
}
|
|
117
|
+
invalidate(files) {
|
|
118
|
+
this.modifiedFiles.clear();
|
|
119
|
+
for (let file of files) {
|
|
120
|
+
// Normalize separators to allow matching TypeScript Host paths
|
|
121
|
+
if (USING_WINDOWS) {
|
|
122
|
+
file = file.replace(WINDOWS_SEP_REGEXP, path.posix.sep);
|
|
123
|
+
}
|
|
124
|
+
this.delete(file);
|
|
125
|
+
this.modifiedFiles.add(file);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.SourceFileCache = SourceFileCache;
|
|
109
130
|
// This is a non-watch version of the compiler code from `@ngtools/webpack` augmented for esbuild
|
|
110
131
|
// eslint-disable-next-line max-lines-per-function
|
|
111
132
|
function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
@@ -160,6 +181,9 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
160
181
|
let fileEmitter;
|
|
161
182
|
// The stylesheet resources from component stylesheets that will be added to the build results output files
|
|
162
183
|
let stylesheetResourceFiles;
|
|
184
|
+
let previousBuilder;
|
|
185
|
+
let previousAngularProgram;
|
|
186
|
+
const babelMemoryCache = new Map();
|
|
163
187
|
build.onStart(async () => {
|
|
164
188
|
var _a, _b;
|
|
165
189
|
const result = {};
|
|
@@ -201,22 +225,34 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
201
225
|
stylesheetResourceFiles.push(...resourceFiles);
|
|
202
226
|
return { content: contents };
|
|
203
227
|
};
|
|
228
|
+
// Temporary deep import for host augmentation support
|
|
229
|
+
const { augmentHostWithCaching, augmentHostWithReplacements, augmentProgramWithVersioning, } = require('@ngtools/webpack/src/ivy/host');
|
|
204
230
|
// Augment TypeScript Host for file replacements option
|
|
205
231
|
if (pluginOptions.fileReplacements) {
|
|
206
|
-
// Temporary deep import for file replacements support
|
|
207
|
-
const { augmentHostWithReplacements } = require('@ngtools/webpack/src/ivy/host');
|
|
208
232
|
augmentHostWithReplacements(host, pluginOptions.fileReplacements);
|
|
209
233
|
}
|
|
234
|
+
// Augment TypeScript Host with source file caching if provided
|
|
235
|
+
if (pluginOptions.sourceFileCache) {
|
|
236
|
+
augmentHostWithCaching(host, pluginOptions.sourceFileCache);
|
|
237
|
+
// Allow the AOT compiler to request the set of changed templates and styles
|
|
238
|
+
host.getModifiedResourceFiles = function () {
|
|
239
|
+
var _a;
|
|
240
|
+
return (_a = pluginOptions.sourceFileCache) === null || _a === void 0 ? void 0 : _a.modifiedFiles;
|
|
241
|
+
};
|
|
242
|
+
}
|
|
210
243
|
// Create the Angular specific program that contains the Angular compiler
|
|
211
|
-
const angularProgram = new compilerCli.NgtscProgram(rootNames, compilerOptions, host);
|
|
244
|
+
const angularProgram = new compilerCli.NgtscProgram(rootNames, compilerOptions, host, previousAngularProgram);
|
|
245
|
+
previousAngularProgram = angularProgram;
|
|
212
246
|
const angularCompiler = angularProgram.compiler;
|
|
213
247
|
const { ignoreForDiagnostics } = angularCompiler;
|
|
214
248
|
const typeScriptProgram = angularProgram.getTsProgram();
|
|
215
|
-
|
|
249
|
+
augmentProgramWithVersioning(typeScriptProgram);
|
|
250
|
+
const builder = typescript_1.default.createEmitAndSemanticDiagnosticsBuilderProgram(typeScriptProgram, host, previousBuilder, configurationDiagnostics);
|
|
251
|
+
previousBuilder = builder;
|
|
216
252
|
await angularCompiler.analyzeAsync();
|
|
217
253
|
function* collectDiagnostics() {
|
|
218
254
|
// Collect program level diagnostics
|
|
219
|
-
yield*
|
|
255
|
+
yield* builder.getConfigFileParsingDiagnostics();
|
|
220
256
|
yield* angularCompiler.getOptionDiagnostics();
|
|
221
257
|
yield* builder.getOptionsDiagnostics();
|
|
222
258
|
yield* builder.getGlobalDiagnostics();
|
|
@@ -243,11 +279,11 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
243
279
|
}
|
|
244
280
|
fileEmitter = createFileEmitter(builder, mergeTransformers(angularCompiler.prepareEmit().transformers, {
|
|
245
281
|
before: [replaceBootstrap(() => builder.getProgram().getTypeChecker())],
|
|
246
|
-
}), () =>
|
|
282
|
+
}), (sourceFile) => angularCompiler.incrementalDriver.recordSuccessfulEmit(sourceFile));
|
|
247
283
|
return result;
|
|
248
284
|
});
|
|
249
285
|
build.onLoad({ filter: compilerOptions.allowJs ? /\.[cm]?[jt]sx?$/ : /\.[cm]?tsx?$/ }, async (args) => {
|
|
250
|
-
var _a, _b, _c
|
|
286
|
+
var _a, _b, _c;
|
|
251
287
|
assert.ok(fileEmitter, 'Invalid plugin execution order');
|
|
252
288
|
const typescriptResult = await fileEmitter((_b = (_a = pluginOptions.fileReplacements) === null || _a === void 0 ? void 0 : _a[args.path]) !== null && _b !== void 0 ? _b : args.path);
|
|
253
289
|
if (!typescriptResult) {
|
|
@@ -260,8 +296,7 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
260
296
|
return {
|
|
261
297
|
errors: [
|
|
262
298
|
{
|
|
263
|
-
text:
|
|
264
|
-
location: { file: args.path },
|
|
299
|
+
text: `File '${args.path}' is missing from the TypeScript compilation.`,
|
|
265
300
|
notes: [
|
|
266
301
|
{
|
|
267
302
|
text: `Ensure the file is part of the TypeScript program via the 'files' or 'include' property.`,
|
|
@@ -271,92 +306,15 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
271
306
|
],
|
|
272
307
|
};
|
|
273
308
|
}
|
|
274
|
-
const data = (_c = typescriptResult.content) !== null && _c !== void 0 ? _c : '';
|
|
275
|
-
const forceAsyncTransformation = /async\s+function\s*\*/.test(data);
|
|
276
|
-
const useInputSourcemap = pluginOptions.sourcemap &&
|
|
277
|
-
(!!pluginOptions.thirdPartySourcemaps || !/[\\/]node_modules[\\/]/.test(args.path));
|
|
278
|
-
// If no additional transformations are needed, return the TypeScript output directly
|
|
279
|
-
if (!forceAsyncTransformation && !pluginOptions.advancedOptimizations) {
|
|
280
|
-
return {
|
|
281
|
-
// Strip sourcemaps if they should not be used
|
|
282
|
-
contents: useInputSourcemap
|
|
283
|
-
? data
|
|
284
|
-
: data.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, ''),
|
|
285
|
-
loader: 'js',
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
const babelResult = await (0, core_1.transformAsync)(data, {
|
|
289
|
-
filename: args.path,
|
|
290
|
-
inputSourceMap: (useInputSourcemap ? undefined : false),
|
|
291
|
-
sourceMaps: pluginOptions.sourcemap ? 'inline' : false,
|
|
292
|
-
compact: false,
|
|
293
|
-
configFile: false,
|
|
294
|
-
babelrc: false,
|
|
295
|
-
browserslistConfigFile: false,
|
|
296
|
-
plugins: [],
|
|
297
|
-
presets: [
|
|
298
|
-
[
|
|
299
|
-
application_1.default,
|
|
300
|
-
{
|
|
301
|
-
forceAsyncTransformation,
|
|
302
|
-
optimize: pluginOptions.advancedOptimizations && {},
|
|
303
|
-
},
|
|
304
|
-
],
|
|
305
|
-
],
|
|
306
|
-
});
|
|
307
309
|
return {
|
|
308
|
-
contents: (
|
|
310
|
+
contents: await transformWithBabelCached(args.path, (_c = typescriptResult.content) !== null && _c !== void 0 ? _c : '', pluginOptions, babelMemoryCache),
|
|
309
311
|
loader: 'js',
|
|
310
312
|
};
|
|
311
313
|
});
|
|
312
314
|
build.onLoad({ filter: /\.[cm]?js$/ }, async (args) => {
|
|
313
|
-
var _a;
|
|
314
315
|
const data = await fs_1.promises.readFile(args.path, 'utf-8');
|
|
315
|
-
const forceAsyncTransformation = !/[\\/][_f]?esm2015[\\/]/.test(args.path) && /async\s+function\s*\*/.test(data);
|
|
316
|
-
const shouldLink = await (0, webpack_loader_1.requiresLinking)(args.path, data);
|
|
317
|
-
const useInputSourcemap = pluginOptions.sourcemap &&
|
|
318
|
-
(!!pluginOptions.thirdPartySourcemaps || !/[\\/]node_modules[\\/]/.test(args.path));
|
|
319
|
-
// If no additional transformations are needed, return the TypeScript output directly
|
|
320
|
-
if (!forceAsyncTransformation && !pluginOptions.advancedOptimizations && !shouldLink) {
|
|
321
|
-
return {
|
|
322
|
-
// Strip sourcemaps if they should not be used
|
|
323
|
-
contents: useInputSourcemap
|
|
324
|
-
? data
|
|
325
|
-
: data.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, ''),
|
|
326
|
-
loader: 'js',
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
const angularPackage = /[\\/]node_modules[\\/]@angular[\\/]/.test(args.path);
|
|
330
|
-
const linkerPluginCreator = (await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker/babel')).createEs2015LinkerPlugin;
|
|
331
|
-
const result = await (0, core_1.transformAsync)(data, {
|
|
332
|
-
filename: args.path,
|
|
333
|
-
inputSourceMap: (useInputSourcemap ? undefined : false),
|
|
334
|
-
sourceMaps: pluginOptions.sourcemap ? 'inline' : false,
|
|
335
|
-
compact: false,
|
|
336
|
-
configFile: false,
|
|
337
|
-
babelrc: false,
|
|
338
|
-
browserslistConfigFile: false,
|
|
339
|
-
plugins: [],
|
|
340
|
-
presets: [
|
|
341
|
-
[
|
|
342
|
-
application_1.default,
|
|
343
|
-
{
|
|
344
|
-
angularLinker: {
|
|
345
|
-
shouldLink,
|
|
346
|
-
jitMode: false,
|
|
347
|
-
linkerPluginCreator,
|
|
348
|
-
},
|
|
349
|
-
forceAsyncTransformation,
|
|
350
|
-
optimize: pluginOptions.advancedOptimizations && {
|
|
351
|
-
looseEnums: angularPackage,
|
|
352
|
-
pureTopLevel: angularPackage,
|
|
353
|
-
},
|
|
354
|
-
},
|
|
355
|
-
],
|
|
356
|
-
],
|
|
357
|
-
});
|
|
358
316
|
return {
|
|
359
|
-
contents: (
|
|
317
|
+
contents: await transformWithBabelCached(args.path, data, pluginOptions, babelMemoryCache),
|
|
360
318
|
loader: 'js',
|
|
361
319
|
};
|
|
362
320
|
});
|
|
@@ -386,3 +344,69 @@ function createFileEmitter(program, transformers = {}, onAfterEmit) {
|
|
|
386
344
|
return { content, dependencies: [] };
|
|
387
345
|
};
|
|
388
346
|
}
|
|
347
|
+
async function transformWithBabel(filename, data, pluginOptions) {
|
|
348
|
+
var _a;
|
|
349
|
+
const forceAsyncTransformation = !/[\\/][_f]?esm2015[\\/]/.test(filename) && /async\s+function\s*\*/.test(data);
|
|
350
|
+
const shouldLink = await (0, webpack_loader_1.requiresLinking)(filename, data);
|
|
351
|
+
const useInputSourcemap = pluginOptions.sourcemap &&
|
|
352
|
+
(!!pluginOptions.thirdPartySourcemaps || !/[\\/]node_modules[\\/]/.test(filename));
|
|
353
|
+
// If no additional transformations are needed, return the data directly
|
|
354
|
+
if (!forceAsyncTransformation && !pluginOptions.advancedOptimizations && !shouldLink) {
|
|
355
|
+
// Strip sourcemaps if they should not be used
|
|
356
|
+
return useInputSourcemap ? data : data.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, '');
|
|
357
|
+
}
|
|
358
|
+
const angularPackage = /[\\/]node_modules[\\/]@angular[\\/]/.test(filename);
|
|
359
|
+
const linkerPluginCreator = shouldLink
|
|
360
|
+
? (await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker/babel')).createEs2015LinkerPlugin
|
|
361
|
+
: undefined;
|
|
362
|
+
const result = await (0, core_1.transformAsync)(data, {
|
|
363
|
+
filename,
|
|
364
|
+
inputSourceMap: (useInputSourcemap ? undefined : false),
|
|
365
|
+
sourceMaps: pluginOptions.sourcemap ? 'inline' : false,
|
|
366
|
+
compact: false,
|
|
367
|
+
configFile: false,
|
|
368
|
+
babelrc: false,
|
|
369
|
+
browserslistConfigFile: false,
|
|
370
|
+
plugins: [],
|
|
371
|
+
presets: [
|
|
372
|
+
[
|
|
373
|
+
application_1.default,
|
|
374
|
+
{
|
|
375
|
+
angularLinker: {
|
|
376
|
+
shouldLink,
|
|
377
|
+
jitMode: false,
|
|
378
|
+
linkerPluginCreator,
|
|
379
|
+
},
|
|
380
|
+
forceAsyncTransformation,
|
|
381
|
+
optimize: pluginOptions.advancedOptimizations && {
|
|
382
|
+
looseEnums: angularPackage,
|
|
383
|
+
pureTopLevel: angularPackage,
|
|
384
|
+
},
|
|
385
|
+
},
|
|
386
|
+
],
|
|
387
|
+
],
|
|
388
|
+
});
|
|
389
|
+
return (_a = result === null || result === void 0 ? void 0 : result.code) !== null && _a !== void 0 ? _a : data;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Transforms JavaScript file data using the babel transforms setup in transformWithBabel. The
|
|
393
|
+
* supplied cache will be used to avoid repeating the transforms for data that has previously
|
|
394
|
+
* been transformed such as in a previous rebuild cycle.
|
|
395
|
+
* @param filename The file path of the data to be transformed.
|
|
396
|
+
* @param data The file data that will be transformed.
|
|
397
|
+
* @param pluginOptions Compiler plugin options that will be used to control the transformation.
|
|
398
|
+
* @param cache A cache of previously transformed data that will be used to avoid repeat transforms.
|
|
399
|
+
* @returns A promise containing the transformed data.
|
|
400
|
+
*/
|
|
401
|
+
async function transformWithBabelCached(filename, data, pluginOptions, cache) {
|
|
402
|
+
// The pre-transformed data is used as a cache key. Since the cache is memory only,
|
|
403
|
+
// the options cannot change and do not need to be represented in the key. If the
|
|
404
|
+
// cache is later stored to disk, then the options that affect transform output
|
|
405
|
+
// would need to be added to the key as well.
|
|
406
|
+
let result = cache.get(data);
|
|
407
|
+
if (result === undefined) {
|
|
408
|
+
result = await transformWithBabel(filename, data, pluginOptions);
|
|
409
|
+
cache.set(data, result);
|
|
410
|
+
}
|
|
411
|
+
return result;
|
|
412
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { BuilderContext } from '@angular-devkit/architect';
|
|
9
|
-
import { BuildFailure, BuildOptions, BuildResult, Message, OutputFile } from 'esbuild';
|
|
9
|
+
import { BuildFailure, BuildInvalidate, BuildOptions, BuildResult, Message, OutputFile } from 'esbuild';
|
|
10
10
|
/**
|
|
11
11
|
* Determines if an unknown value is an esbuild BuildFailure error object thrown by esbuild.
|
|
12
12
|
* @param value A potential esbuild BuildFailure error object.
|
|
@@ -19,11 +19,12 @@ export declare function isEsBuildFailure(value: unknown): value is BuildFailure;
|
|
|
19
19
|
* All builds use the `write` option with a value of `false` to allow for the output files
|
|
20
20
|
* build result array to be populated.
|
|
21
21
|
*
|
|
22
|
-
* @param
|
|
22
|
+
* @param optionsOrInvalidate The esbuild options object to use when building or the invalidate object
|
|
23
|
+
* returned from an incremental build to perform an additional incremental build.
|
|
23
24
|
* @returns If output files are generated, the full esbuild BuildResult; if not, the
|
|
24
25
|
* warnings and errors for the attempted build.
|
|
25
26
|
*/
|
|
26
|
-
export declare function bundle(
|
|
27
|
+
export declare function bundle(optionsOrInvalidate: BuildOptions | BuildInvalidate): Promise<(BuildResult & {
|
|
27
28
|
outputFiles: OutputFile[];
|
|
28
29
|
}) | (BuildFailure & {
|
|
29
30
|
outputFiles?: never;
|
|
@@ -24,16 +24,22 @@ exports.isEsBuildFailure = isEsBuildFailure;
|
|
|
24
24
|
* All builds use the `write` option with a value of `false` to allow for the output files
|
|
25
25
|
* build result array to be populated.
|
|
26
26
|
*
|
|
27
|
-
* @param
|
|
27
|
+
* @param optionsOrInvalidate The esbuild options object to use when building or the invalidate object
|
|
28
|
+
* returned from an incremental build to perform an additional incremental build.
|
|
28
29
|
* @returns If output files are generated, the full esbuild BuildResult; if not, the
|
|
29
30
|
* warnings and errors for the attempted build.
|
|
30
31
|
*/
|
|
31
|
-
async function bundle(
|
|
32
|
+
async function bundle(optionsOrInvalidate) {
|
|
32
33
|
try {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
if (typeof optionsOrInvalidate === 'function') {
|
|
35
|
+
return (await optionsOrInvalidate());
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return await (0, esbuild_1.build)({
|
|
39
|
+
...optionsOrInvalidate,
|
|
40
|
+
write: false,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
37
43
|
}
|
|
38
44
|
catch (failure) {
|
|
39
45
|
// Build failures will throw an exception which contains errors/warnings
|
|
@@ -24,9 +24,6 @@ const UNSUPPORTED_OPTIONS = [
|
|
|
24
24
|
'inlineStyleLanguage',
|
|
25
25
|
// The following option has no effect until preprocessors are supported
|
|
26
26
|
// 'stylePreprocessorOptions',
|
|
27
|
-
// * Watch mode
|
|
28
|
-
'watch',
|
|
29
|
-
'poll',
|
|
30
27
|
// * Deprecated
|
|
31
28
|
'deployUrl',
|
|
32
29
|
// * Always enabled with esbuild
|
|
@@ -10,10 +10,10 @@ import { Schema as BrowserBuilderOptions } from './schema';
|
|
|
10
10
|
/**
|
|
11
11
|
* Main execution function for the esbuild-based application builder.
|
|
12
12
|
* The options are compatible with the Webpack-based builder.
|
|
13
|
-
* @param
|
|
13
|
+
* @param initialOptions The browser builder options to use when setting up the application build
|
|
14
14
|
* @param context The Architect builder context object
|
|
15
|
-
* @returns
|
|
15
|
+
* @returns An async iterable with the builder result output
|
|
16
16
|
*/
|
|
17
|
-
export declare function buildEsbuildBrowser(
|
|
17
|
+
export declare function buildEsbuildBrowser(initialOptions: BrowserBuilderOptions, context: BuilderContext): AsyncIterable<BuilderOutput>;
|
|
18
18
|
declare const _default: import("@angular-devkit/architect/src/internal").Builder<BrowserBuilderOptions & import("../../../../core/src").JsonObject>;
|
|
19
19
|
export default _default;
|