@angular-devkit/build-angular 17.0.0-rc.1 → 17.0.0-rc.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 +7 -7
- package/src/builders/application/execute-build.js +2 -2
- package/src/builders/browser-esbuild/index.js +9 -1
- package/src/builders/dev-server/vite-server.js +19 -6
- package/src/tools/esbuild/application-code-bundle.js +2 -9
- package/src/tools/esbuild/bundler-context.d.ts +1 -1
- package/src/tools/esbuild/bundler-context.js +7 -2
- package/src/tools/esbuild/global-scripts.d.ts +2 -3
- package/src/tools/esbuild/global-scripts.js +72 -69
- package/src/tools/esbuild/global-styles.d.ts +2 -3
- package/src/tools/esbuild/global-styles.js +35 -33
- package/src/tools/esbuild/javascript-transformer-worker.js +3 -2
- package/src/tools/esbuild/watcher.d.ts +1 -0
- package/src/tools/esbuild/watcher.js +3 -0
- package/src/utils/check-port.js +3 -1
- package/src/utils/load-esm.d.ts +0 -2
- package/src/tools/esbuild/javascript-transfomer-plugin.d.ts +0 -19
- package/src/tools/esbuild/javascript-transfomer-plugin.js +0 -51
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "17.0.0-rc.
|
|
3
|
+
"version": "17.0.0-rc.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.1",
|
|
10
|
-
"@angular-devkit/architect": "0.1700.0-rc.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1700.0-rc.
|
|
12
|
-
"@angular-devkit/core": "17.0.0-rc.
|
|
10
|
+
"@angular-devkit/architect": "0.1700.0-rc.2",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1700.0-rc.2",
|
|
12
|
+
"@angular-devkit/core": "17.0.0-rc.2",
|
|
13
13
|
"@babel/core": "7.23.2",
|
|
14
14
|
"@babel/generator": "7.23.0",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.22.5",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@babel/preset-env": "7.23.2",
|
|
21
21
|
"@babel/runtime": "7.23.2",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.7",
|
|
23
|
-
"@ngtools/webpack": "17.0.0-rc.
|
|
23
|
+
"@ngtools/webpack": "17.0.0-rc.2",
|
|
24
24
|
"@vitejs/plugin-basic-ssl": "1.0.1",
|
|
25
25
|
"ansi-colors": "4.1.3",
|
|
26
26
|
"autoprefixer": "10.4.16",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"fast-glob": "3.3.1",
|
|
37
37
|
"https-proxy-agent": "7.0.2",
|
|
38
38
|
"http-proxy-middleware": "2.0.6",
|
|
39
|
-
"inquirer": "
|
|
39
|
+
"inquirer": "9.2.11",
|
|
40
40
|
"jsonc-parser": "3.2.0",
|
|
41
41
|
"karma-source-map-support": "1.4.0",
|
|
42
42
|
"less": "4.2.0",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"postcss-loader": "7.3.3",
|
|
56
56
|
"resolve-url-loader": "5.0.0",
|
|
57
57
|
"rxjs": "7.8.1",
|
|
58
|
-
"sass": "1.69.
|
|
58
|
+
"sass": "1.69.5",
|
|
59
59
|
"sass-loader": "13.3.2",
|
|
60
60
|
"semver": "7.5.4",
|
|
61
61
|
"source-map-loader": "4.0.1",
|
|
@@ -49,7 +49,7 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
49
49
|
// Global Stylesheets
|
|
50
50
|
if (options.globalStyles.length > 0) {
|
|
51
51
|
for (const initial of [true, false]) {
|
|
52
|
-
const bundleOptions = (0, global_styles_1.createGlobalStylesBundleOptions)(options, target, initial
|
|
52
|
+
const bundleOptions = (0, global_styles_1.createGlobalStylesBundleOptions)(options, target, initial);
|
|
53
53
|
if (bundleOptions) {
|
|
54
54
|
bundlerContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, !!options.watch, bundleOptions, () => initial));
|
|
55
55
|
}
|
|
@@ -76,7 +76,7 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
const bundlingResult = await bundler_context_1.BundlerContext.bundleAll(bundlerContexts);
|
|
79
|
+
const bundlingResult = await bundler_context_1.BundlerContext.bundleAll(bundlerContexts, rebuildState?.fileChanges.all);
|
|
80
80
|
// Log all warnings and errors generated during bundling
|
|
81
81
|
await (0, utils_1.logMessages)(context, bundlingResult);
|
|
82
82
|
const executionResult = new bundler_execution_result_1.ExecutionResult(bundlerContexts, codeBundleCache);
|
|
@@ -37,7 +37,15 @@ async function* buildEsbuildBrowser(userOptions, context, infrastructureSettings
|
|
|
37
37
|
// Write output files
|
|
38
38
|
await writeResultFiles(result.outputFiles, result.assetFiles, fullOutputPath);
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
// The builder system (architect) currently attempts to treat all results as JSON and
|
|
41
|
+
// attempts to validate the object with a JSON schema validator. This can lead to slow
|
|
42
|
+
// build completion (even after the actual build is fully complete) or crashes if the
|
|
43
|
+
// size and/or quantity of output files is large. Architect only requires a `success`
|
|
44
|
+
// property so that is all that will be passed here if the infrastructure settings have
|
|
45
|
+
// not been explicitly set to avoid writes. Writing is only disabled when used directly
|
|
46
|
+
// by the dev server which bypasses the architect behavior.
|
|
47
|
+
const builderResult = infrastructureSettings?.write === false ? result : { success: result.success };
|
|
48
|
+
yield builderResult;
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
51
|
exports.buildEsbuildBrowser = buildEsbuildBrowser;
|
|
@@ -148,11 +148,13 @@ async function* serveWithVite(serverOptions, builderName, context, plugins) {
|
|
|
148
148
|
}
|
|
149
149
|
// To avoid disconnecting the array objects from the option, these arrays need to be mutated
|
|
150
150
|
// instead of replaced.
|
|
151
|
-
if (result.externalMetadata
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
151
|
+
if (result.externalMetadata) {
|
|
152
|
+
if (result.externalMetadata.explicit) {
|
|
153
|
+
externalMetadata.explicit.push(...result.externalMetadata.explicit);
|
|
154
|
+
}
|
|
155
|
+
if (result.externalMetadata.implicit) {
|
|
156
|
+
externalMetadata.implicit.push(...result.externalMetadata.implicit);
|
|
157
|
+
}
|
|
156
158
|
}
|
|
157
159
|
if (server) {
|
|
158
160
|
handleUpdate(generatedFiles, server, serverOptions, context.logger);
|
|
@@ -308,6 +310,9 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
308
310
|
watch: {
|
|
309
311
|
ignored: ['**/*'],
|
|
310
312
|
},
|
|
313
|
+
// This is needed when `externalDependencies` is used to prevent Vite load errors.
|
|
314
|
+
// NOTE: If Vite adds direct support for externals, this can be removed.
|
|
315
|
+
preTransformRequests: externalMetadata.explicit.length === 0,
|
|
311
316
|
},
|
|
312
317
|
ssr: {
|
|
313
318
|
// Exclude any provided dependencies (currently build defined externals)
|
|
@@ -320,6 +325,12 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
320
325
|
// Ensures plugin hooks run before built-in Vite hooks
|
|
321
326
|
enforce: 'pre',
|
|
322
327
|
async resolveId(source, importer) {
|
|
328
|
+
// Prevent vite from resolving an explicit external dependency (`externalDependencies` option)
|
|
329
|
+
if (externalMetadata.explicit.includes(source)) {
|
|
330
|
+
// This is still not ideal since Vite will still transform the import specifier to
|
|
331
|
+
// `/@id/${source}` but is currently closer to a raw external than a resolved file path.
|
|
332
|
+
return source;
|
|
333
|
+
}
|
|
323
334
|
if (importer && source.startsWith('.')) {
|
|
324
335
|
// Remove query if present
|
|
325
336
|
const [importerFile] = importer.split('?', 1);
|
|
@@ -417,9 +428,11 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
417
428
|
return;
|
|
418
429
|
}
|
|
419
430
|
transformIndexHtmlAndAddHeaders(url, rawHtml, res, next, async (html) => {
|
|
431
|
+
const protocol = serverOptions.ssl ? 'https' : 'http';
|
|
432
|
+
const route = `${protocol}://${req.headers.host}${req.originalUrl}`;
|
|
420
433
|
const { content } = await (0, render_page_1.renderPage)({
|
|
421
434
|
document: html,
|
|
422
|
-
route
|
|
435
|
+
route,
|
|
423
436
|
serverContext: 'ssr',
|
|
424
437
|
loadBundle: (path) =>
|
|
425
438
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -19,7 +19,6 @@ const environment_options_1 = require("../../utils/environment-options");
|
|
|
19
19
|
const compiler_plugin_1 = require("./angular/compiler-plugin");
|
|
20
20
|
const compiler_plugin_options_1 = require("./compiler-plugin-options");
|
|
21
21
|
const i18n_locale_plugin_1 = require("./i18n-locale-plugin");
|
|
22
|
-
const javascript_transfomer_plugin_1 = require("./javascript-transfomer-plugin");
|
|
23
22
|
const rxjs_esm_resolution_plugin_1 = require("./rxjs-esm-resolution-plugin");
|
|
24
23
|
const sourcemap_ignorelist_plugin_1 = require("./sourcemap-ignorelist-plugin");
|
|
25
24
|
const utils_1 = require("./utils");
|
|
@@ -195,7 +194,7 @@ function createServerPolyfillBundleOptions(options, target, sourceFileCache) {
|
|
|
195
194
|
if (!polyfillBundleOptions) {
|
|
196
195
|
return;
|
|
197
196
|
}
|
|
198
|
-
const { workspaceRoot
|
|
197
|
+
const { workspaceRoot } = options;
|
|
199
198
|
const buildOptions = {
|
|
200
199
|
...polyfillBundleOptions,
|
|
201
200
|
platform: 'node',
|
|
@@ -232,13 +231,7 @@ function createServerPolyfillBundleOptions(options, target, sourceFileCache) {
|
|
|
232
231
|
}),
|
|
233
232
|
}));
|
|
234
233
|
}
|
|
235
|
-
buildOptions.plugins.push((0, rxjs_esm_resolution_plugin_1.createRxjsEsmResolutionPlugin)()
|
|
236
|
-
jit,
|
|
237
|
-
sourcemap: !!sourcemapOptions.scripts,
|
|
238
|
-
babelFileCache: sourceFileCache?.babelFileCache,
|
|
239
|
-
advancedOptimizations,
|
|
240
|
-
maxWorkers: 1,
|
|
241
|
-
}));
|
|
234
|
+
buildOptions.plugins.push((0, rxjs_esm_resolution_plugin_1.createRxjsEsmResolutionPlugin)());
|
|
242
235
|
return buildOptions;
|
|
243
236
|
}
|
|
244
237
|
exports.createServerPolyfillBundleOptions = createServerPolyfillBundleOptions;
|
|
@@ -43,7 +43,7 @@ export declare class BundlerContext {
|
|
|
43
43
|
private initialFilter?;
|
|
44
44
|
readonly watchFiles: Set<string>;
|
|
45
45
|
constructor(workspaceRoot: string, incremental: boolean, options: BuildOptions | BundlerOptionsFactory, initialFilter?: ((initial: Readonly<InitialFileRecord>) => boolean) | undefined);
|
|
46
|
-
static bundleAll(contexts: Iterable<BundlerContext>): Promise<BundleContextResult>;
|
|
46
|
+
static bundleAll(contexts: Iterable<BundlerContext>, changedFiles?: Iterable<string>): Promise<BundleContextResult>;
|
|
47
47
|
/**
|
|
48
48
|
* Executes the esbuild build function and normalizes the build result in the event of a
|
|
49
49
|
* build failure that results in no output being generated.
|
|
@@ -53,8 +53,13 @@ class BundlerContext {
|
|
|
53
53
|
};
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
static async bundleAll(contexts) {
|
|
57
|
-
const individualResults = await Promise.all([...contexts].map((context) =>
|
|
56
|
+
static async bundleAll(contexts, changedFiles) {
|
|
57
|
+
const individualResults = await Promise.all([...contexts].map((context) => {
|
|
58
|
+
if (changedFiles) {
|
|
59
|
+
context.invalidate(changedFiles);
|
|
60
|
+
}
|
|
61
|
+
return context.bundle();
|
|
62
|
+
}));
|
|
58
63
|
// Return directly if only one result
|
|
59
64
|
if (individualResults.length === 1) {
|
|
60
65
|
return individualResults[0];
|
|
@@ -5,13 +5,12 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import type { BuildOptions } from 'esbuild';
|
|
9
8
|
import type { NormalizedApplicationBuildOptions } from '../../builders/application/options';
|
|
10
|
-
import {
|
|
9
|
+
import { BundlerOptionsFactory } from './bundler-context';
|
|
11
10
|
/**
|
|
12
11
|
* Create an esbuild 'build' options object for all global scripts defined in the user provied
|
|
13
12
|
* build options.
|
|
14
13
|
* @param options The builder's user-provider normalized options.
|
|
15
14
|
* @returns An esbuild BuildOptions object.
|
|
16
15
|
*/
|
|
17
|
-
export declare function createGlobalScriptsBundleOptions(options: NormalizedApplicationBuildOptions, initial: boolean
|
|
16
|
+
export declare function createGlobalScriptsBundleOptions(options: NormalizedApplicationBuildOptions, initial: boolean): BundlerOptionsFactory | undefined;
|
|
@@ -48,7 +48,7 @@ const virtual_module_plugin_1 = require("./virtual-module-plugin");
|
|
|
48
48
|
* @param options The builder's user-provider normalized options.
|
|
49
49
|
* @returns An esbuild BuildOptions object.
|
|
50
50
|
*/
|
|
51
|
-
function createGlobalScriptsBundleOptions(options, initial
|
|
51
|
+
function createGlobalScriptsBundleOptions(options, initial) {
|
|
52
52
|
const { globalScripts, optimizationOptions, outputNames, preserveSymlinks, sourcemapOptions, workspaceRoot, } = options;
|
|
53
53
|
const namespace = 'angular:script/global';
|
|
54
54
|
const entryPoints = {};
|
|
@@ -63,77 +63,80 @@ function createGlobalScriptsBundleOptions(options, initial, loadCache) {
|
|
|
63
63
|
if (found === false) {
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
|
-
return {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
(0, error_1.assertIsError)(e);
|
|
107
|
-
if (e.code !== 'ENOENT') {
|
|
108
|
-
throw e;
|
|
66
|
+
return (loadCache) => {
|
|
67
|
+
return {
|
|
68
|
+
absWorkingDir: workspaceRoot,
|
|
69
|
+
bundle: false,
|
|
70
|
+
splitting: false,
|
|
71
|
+
entryPoints,
|
|
72
|
+
entryNames: initial ? outputNames.bundles : '[name]',
|
|
73
|
+
assetNames: outputNames.media,
|
|
74
|
+
mainFields: ['script', 'browser', 'main'],
|
|
75
|
+
conditions: ['script'],
|
|
76
|
+
resolveExtensions: ['.mjs', '.js'],
|
|
77
|
+
logLevel: options.verbose ? 'debug' : 'silent',
|
|
78
|
+
metafile: true,
|
|
79
|
+
minify: optimizationOptions.scripts,
|
|
80
|
+
outdir: workspaceRoot,
|
|
81
|
+
sourcemap: sourcemapOptions.scripts && (sourcemapOptions.hidden ? 'external' : true),
|
|
82
|
+
write: false,
|
|
83
|
+
platform: 'neutral',
|
|
84
|
+
preserveSymlinks,
|
|
85
|
+
plugins: [
|
|
86
|
+
(0, sourcemap_ignorelist_plugin_1.createSourcemapIgnorelistPlugin)(),
|
|
87
|
+
(0, virtual_module_plugin_1.createVirtualModulePlugin)({
|
|
88
|
+
namespace,
|
|
89
|
+
external: true,
|
|
90
|
+
// Add the `js` extension here so that esbuild generates an output file with the extension
|
|
91
|
+
transformPath: (path) => path.slice(namespace.length + 1) + '.js',
|
|
92
|
+
loadContent: (args, build) => (0, load_result_cache_1.createCachedLoad)(loadCache, async (args) => {
|
|
93
|
+
const files = globalScripts.find(({ name }) => name === args.path.slice(0, -3))
|
|
94
|
+
?.files;
|
|
95
|
+
(0, node_assert_1.default)(files, `Invalid operation: global scripts name not found [${args.path}]`);
|
|
96
|
+
// Global scripts are concatenated using magic-string instead of bundled via esbuild.
|
|
97
|
+
const bundleContent = new magic_string_1.Bundle();
|
|
98
|
+
const watchFiles = [];
|
|
99
|
+
for (const filename of files) {
|
|
100
|
+
let fileContent;
|
|
101
|
+
try {
|
|
102
|
+
// Attempt to read as a relative path from the workspace root
|
|
103
|
+
const fullPath = node_path_1.default.join(workspaceRoot, filename);
|
|
104
|
+
fileContent = await (0, promises_1.readFile)(fullPath, 'utf-8');
|
|
105
|
+
watchFiles.push(fullPath);
|
|
109
106
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
107
|
+
catch (e) {
|
|
108
|
+
(0, error_1.assertIsError)(e);
|
|
109
|
+
if (e.code !== 'ENOENT') {
|
|
110
|
+
throw e;
|
|
111
|
+
}
|
|
112
|
+
// If not found, attempt to resolve as a module specifier
|
|
113
|
+
const resolveResult = await build.resolve(filename, {
|
|
114
|
+
kind: 'entry-point',
|
|
115
|
+
resolveDir: workspaceRoot,
|
|
116
|
+
});
|
|
117
|
+
if (resolveResult.errors.length) {
|
|
118
|
+
// Remove resolution failure notes about marking as external since it doesn't apply
|
|
119
|
+
// to global scripts.
|
|
120
|
+
resolveResult.errors.forEach((error) => (error.notes = []));
|
|
121
|
+
return {
|
|
122
|
+
errors: resolveResult.errors,
|
|
123
|
+
warnings: resolveResult.warnings,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
watchFiles.push(resolveResult.path);
|
|
127
|
+
fileContent = await (0, promises_1.readFile)(resolveResult.path, 'utf-8');
|
|
123
128
|
}
|
|
124
|
-
|
|
125
|
-
fileContent = await (0, promises_1.readFile)(resolveResult.path, 'utf-8');
|
|
129
|
+
bundleContent.addSource(new magic_string_1.default(fileContent, { filename }));
|
|
126
130
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
],
|
|
131
|
+
return {
|
|
132
|
+
contents: bundleContent.toString(),
|
|
133
|
+
loader: 'js',
|
|
134
|
+
watchFiles,
|
|
135
|
+
};
|
|
136
|
+
}).call(build, args),
|
|
137
|
+
}),
|
|
138
|
+
],
|
|
139
|
+
};
|
|
137
140
|
};
|
|
138
141
|
}
|
|
139
142
|
exports.createGlobalScriptsBundleOptions = createGlobalScriptsBundleOptions;
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import type { BuildOptions } from 'esbuild';
|
|
9
8
|
import { NormalizedApplicationBuildOptions } from '../../builders/application/options';
|
|
10
|
-
import {
|
|
11
|
-
export declare function createGlobalStylesBundleOptions(options: NormalizedApplicationBuildOptions, target: string[], initial: boolean
|
|
9
|
+
import { BundlerOptionsFactory } from './bundler-context';
|
|
10
|
+
export declare function createGlobalStylesBundleOptions(options: NormalizedApplicationBuildOptions, target: string[], initial: boolean): BundlerOptionsFactory | undefined;
|
|
@@ -14,7 +14,7 @@ exports.createGlobalStylesBundleOptions = void 0;
|
|
|
14
14
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
15
15
|
const bundle_options_1 = require("./stylesheets/bundle-options");
|
|
16
16
|
const virtual_module_plugin_1 = require("./virtual-module-plugin");
|
|
17
|
-
function createGlobalStylesBundleOptions(options, target, initial
|
|
17
|
+
function createGlobalStylesBundleOptions(options, target, initial) {
|
|
18
18
|
const { workspaceRoot, optimizationOptions, sourcemapOptions, outputNames, globalStyles, preserveSymlinks, externalDependencies, stylePreprocessorOptions, tailwindConfiguration, } = options;
|
|
19
19
|
const namespace = 'angular:styles/global';
|
|
20
20
|
const entryPoints = {};
|
|
@@ -29,38 +29,40 @@ function createGlobalStylesBundleOptions(options, target, initial, cache) {
|
|
|
29
29
|
if (found === false) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
return (loadCache) => {
|
|
33
|
+
const buildOptions = (0, bundle_options_1.createStylesheetBundleOptions)({
|
|
34
|
+
workspaceRoot,
|
|
35
|
+
optimization: !!optimizationOptions.styles.minify,
|
|
36
|
+
sourcemap: !!sourcemapOptions.styles,
|
|
37
|
+
preserveSymlinks,
|
|
38
|
+
target,
|
|
39
|
+
externalDependencies,
|
|
40
|
+
outputNames: initial
|
|
41
|
+
? outputNames
|
|
42
|
+
: {
|
|
43
|
+
...outputNames,
|
|
44
|
+
bundles: '[name]',
|
|
45
|
+
},
|
|
46
|
+
includePaths: stylePreprocessorOptions?.includePaths,
|
|
47
|
+
tailwindConfiguration,
|
|
48
|
+
publicPath: options.publicPath,
|
|
49
|
+
}, loadCache);
|
|
50
|
+
buildOptions.legalComments = options.extractLicenses ? 'none' : 'eof';
|
|
51
|
+
buildOptions.entryPoints = entryPoints;
|
|
52
|
+
buildOptions.plugins.unshift((0, virtual_module_plugin_1.createVirtualModulePlugin)({
|
|
53
|
+
namespace,
|
|
54
|
+
transformPath: (path) => path.split(';', 2)[1],
|
|
55
|
+
loadContent: (args) => {
|
|
56
|
+
const files = globalStyles.find(({ name }) => name === args.path)?.files;
|
|
57
|
+
(0, node_assert_1.default)(files, `global style name should always be found [${args.path}]`);
|
|
58
|
+
return {
|
|
59
|
+
contents: files.map((file) => `@import '${file.replace(/\\/g, '/')}';`).join('\n'),
|
|
60
|
+
loader: 'css',
|
|
61
|
+
resolveDir: workspaceRoot,
|
|
62
|
+
};
|
|
44
63
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}, cache);
|
|
49
|
-
buildOptions.legalComments = options.extractLicenses ? 'none' : 'eof';
|
|
50
|
-
buildOptions.entryPoints = entryPoints;
|
|
51
|
-
buildOptions.plugins.unshift((0, virtual_module_plugin_1.createVirtualModulePlugin)({
|
|
52
|
-
namespace,
|
|
53
|
-
transformPath: (path) => path.split(';', 2)[1],
|
|
54
|
-
loadContent: (args) => {
|
|
55
|
-
const files = globalStyles.find(({ name }) => name === args.path)?.files;
|
|
56
|
-
(0, node_assert_1.default)(files, `global style name should always be found [${args.path}]`);
|
|
57
|
-
return {
|
|
58
|
-
contents: files.map((file) => `@import '${file.replace(/\\/g, '/')}';`).join('\n'),
|
|
59
|
-
loader: 'css',
|
|
60
|
-
resolveDir: workspaceRoot,
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
|
-
}));
|
|
64
|
-
return buildOptions;
|
|
64
|
+
}));
|
|
65
|
+
return buildOptions;
|
|
66
|
+
};
|
|
65
67
|
}
|
|
66
68
|
exports.createGlobalStylesBundleOptions = createGlobalStylesBundleOptions;
|
|
@@ -50,9 +50,10 @@ async function transformWithBabel({ filename, data, ...options }) {
|
|
|
50
50
|
// Strip sourcemaps if they should not be used
|
|
51
51
|
return useInputSourcemap ? data : data.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, '');
|
|
52
52
|
}
|
|
53
|
-
//
|
|
53
|
+
// `@angular/platform-server/init` and `@angular/common/locales/global` entry-points are side effectful.
|
|
54
54
|
const safeAngularPackage = /[\\/]node_modules[\\/]@angular[\\/]/.test(filename) &&
|
|
55
|
-
!/@angular[\\/]platform-server[\\/]f?esm2022[\\/]init/.test(filename)
|
|
55
|
+
!/@angular[\\/]platform-server[\\/]f?esm2022[\\/]init/.test(filename) &&
|
|
56
|
+
!/@angular[\\/]common[\\/]locales[\\/]global/.test(filename);
|
|
56
57
|
// Lazy load the linker plugin only when linking is required
|
|
57
58
|
if (shouldLink) {
|
|
58
59
|
linkerPluginCreator ??= (await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker/babel')).createEs2015LinkerPlugin;
|
|
@@ -9,6 +9,7 @@ export declare class ChangedFiles {
|
|
|
9
9
|
readonly added: Set<string>;
|
|
10
10
|
readonly modified: Set<string>;
|
|
11
11
|
readonly removed: Set<string>;
|
|
12
|
+
get all(): string[];
|
|
12
13
|
toDebugString(): string;
|
|
13
14
|
}
|
|
14
15
|
export interface BuildWatcher extends AsyncIterableIterator<ChangedFiles> {
|
package/src/utils/check-port.js
CHANGED
|
@@ -32,6 +32,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
33
|
exports.checkPort = void 0;
|
|
34
34
|
const net = __importStar(require("net"));
|
|
35
|
+
const load_esm_1 = require("./load-esm");
|
|
35
36
|
const tty_1 = require("./tty");
|
|
36
37
|
function createInUseError(port) {
|
|
37
38
|
return new Error(`Port ${port} is already in use. Use '--port' to specify a different port.`);
|
|
@@ -52,7 +53,8 @@ async function checkPort(port, host) {
|
|
|
52
53
|
reject(createInUseError(port));
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
(0, load_esm_1.loadEsmModule)('inquirer')
|
|
57
|
+
.then(({ default: { prompt } }) => prompt({
|
|
56
58
|
type: 'confirm',
|
|
57
59
|
name: 'useDifferent',
|
|
58
60
|
message: `Port ${port} is already in use.\nWould you like to use a different port?`,
|
package/src/utils/load-esm.d.ts
CHANGED
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
/// <reference types="node" />
|
|
9
|
-
import { URL } from 'url';
|
|
10
8
|
/**
|
|
11
9
|
* This uses a dynamic import to load a module which may be ESM.
|
|
12
10
|
* CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import type { Plugin } from 'esbuild';
|
|
9
|
-
import { JavaScriptTransformerOptions } from './javascript-transformer';
|
|
10
|
-
export interface JavaScriptTransformerPluginOptions extends JavaScriptTransformerOptions {
|
|
11
|
-
babelFileCache?: Map<string, Uint8Array>;
|
|
12
|
-
maxWorkers: number;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Creates a plugin that Transformers JavaScript using Babel.
|
|
16
|
-
*
|
|
17
|
-
* @returns An esbuild plugin.
|
|
18
|
-
*/
|
|
19
|
-
export declare function createJavaScriptTransformerPlugin(options: JavaScriptTransformerPluginOptions): Plugin;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.createJavaScriptTransformerPlugin = void 0;
|
|
11
|
-
const javascript_transformer_1 = require("./javascript-transformer");
|
|
12
|
-
/**
|
|
13
|
-
* Creates a plugin that Transformers JavaScript using Babel.
|
|
14
|
-
*
|
|
15
|
-
* @returns An esbuild plugin.
|
|
16
|
-
*/
|
|
17
|
-
function createJavaScriptTransformerPlugin(options) {
|
|
18
|
-
return {
|
|
19
|
-
name: 'angular-javascript-transformer',
|
|
20
|
-
setup(build) {
|
|
21
|
-
let javascriptTransformer;
|
|
22
|
-
const { sourcemap, thirdPartySourcemaps, advancedOptimizations, jit, babelFileCache, maxWorkers, } = options;
|
|
23
|
-
build.onLoad({ filter: /\.[cm]?js$/ }, async (args) => {
|
|
24
|
-
// The filename is currently used as a cache key. Since the cache is memory only,
|
|
25
|
-
// the options cannot change and do not need to be represented in the key. If the
|
|
26
|
-
// cache is later stored to disk, then the options that affect transform output
|
|
27
|
-
// would need to be added to the key as well as a check for any change of content.
|
|
28
|
-
let contents = babelFileCache?.get(args.path);
|
|
29
|
-
if (contents === undefined) {
|
|
30
|
-
// Initialize a worker pool for JavaScript transformations
|
|
31
|
-
javascriptTransformer ??= new javascript_transformer_1.JavaScriptTransformer({
|
|
32
|
-
sourcemap,
|
|
33
|
-
thirdPartySourcemaps,
|
|
34
|
-
advancedOptimizations,
|
|
35
|
-
jit,
|
|
36
|
-
}, maxWorkers);
|
|
37
|
-
contents = await javascriptTransformer.transformFile(args.path, jit);
|
|
38
|
-
babelFileCache?.set(args.path, contents);
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
contents,
|
|
42
|
-
loader: 'js',
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
build.onDispose(() => {
|
|
46
|
-
void javascriptTransformer?.close();
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
exports.createJavaScriptTransformerPlugin = createJavaScriptTransformerPlugin;
|