mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-22 06:41:45 +08:00
fix(@angular-devkit/build-angular): add web-workers in lazy chunks in stats output
Web-workers are not marked as `initial` since their initialization can be guarded. Closes #21059
This commit is contained in:
parent
2f03e7a049
commit
c43ace7383
@ -143,12 +143,8 @@ async function initialize(
|
|||||||
// Assets are processed directly by the builder except when watching
|
// Assets are processed directly by the builder except when watching
|
||||||
const adjustedOptions = options.watch ? options : { ...options, assets: [] };
|
const adjustedOptions = options.watch ? options : { ...options, assets: [] };
|
||||||
|
|
||||||
const {
|
const { config, projectRoot, projectSourceRoot, i18n } =
|
||||||
config,
|
await generateI18nBrowserWebpackConfigFromContext(
|
||||||
projectRoot,
|
|
||||||
projectSourceRoot,
|
|
||||||
i18n,
|
|
||||||
} = await generateI18nBrowserWebpackConfigFromContext(
|
|
||||||
adjustedOptions,
|
adjustedOptions,
|
||||||
context,
|
context,
|
||||||
(wco) => [
|
(wco) => [
|
||||||
@ -803,7 +799,6 @@ function generateBundleInfoStats(
|
|||||||
size: bundle.size,
|
size: bundle.size,
|
||||||
files: bundle.map ? [bundle.filename, bundle.map.filename] : [bundle.filename],
|
files: bundle.map ? [bundle.filename, bundle.map.filename] : [bundle.filename],
|
||||||
names: chunk?.names,
|
names: chunk?.names,
|
||||||
entry: !!chunk?.names?.includes('runtime'),
|
|
||||||
initial: !!chunk?.initial,
|
initial: !!chunk?.initial,
|
||||||
rendered: true,
|
rendered: true,
|
||||||
chunkType,
|
chunkType,
|
||||||
|
@ -27,7 +27,9 @@ export function markAsyncChunksNonInitial(
|
|||||||
// **cannot** be loaded in main bundle.
|
// **cannot** be loaded in main bundle.
|
||||||
const asyncChunkIds = extraEntryPoints
|
const asyncChunkIds = extraEntryPoints
|
||||||
.filter((entryPoint) => !entryPoint.inject)
|
.filter((entryPoint) => !entryPoint.inject)
|
||||||
.flatMap((entryPoint) => entryPoints[entryPoint.bundleName].chunks);
|
.flatMap((entryPoint) =>
|
||||||
|
entryPoints[entryPoint.bundleName].chunks?.filter((n) => n !== 'runtime'),
|
||||||
|
);
|
||||||
|
|
||||||
// Find chunks for each ID.
|
// Find chunks for each ID.
|
||||||
const asyncChunks = asyncChunkIds.map((chunkId) => {
|
const asyncChunks = asyncChunkIds.map((chunkId) => {
|
||||||
@ -41,8 +43,12 @@ export function markAsyncChunksNonInitial(
|
|||||||
|
|
||||||
// A chunk is considered `initial` only if Webpack already belives it to be initial
|
// A chunk is considered `initial` only if Webpack already belives it to be initial
|
||||||
// and the application developer did not mark it async via an extra entry point.
|
// and the application developer did not mark it async via an extra entry point.
|
||||||
return chunks.map((chunk) => ({
|
return chunks.map((chunk) => {
|
||||||
|
return asyncChunks.find((asyncChunk) => asyncChunk === chunk)
|
||||||
|
? {
|
||||||
...chunk,
|
...chunk,
|
||||||
initial: chunk.initial && !asyncChunks.find((asyncChunk) => asyncChunk === chunk),
|
initial: false,
|
||||||
}));
|
}
|
||||||
|
: chunk;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,6 @@ export function generateBundleStats(info: {
|
|||||||
size?: number;
|
size?: number;
|
||||||
files?: string[];
|
files?: string[];
|
||||||
names?: string[];
|
names?: string[];
|
||||||
entry?: boolean;
|
|
||||||
initial?: boolean;
|
initial?: boolean;
|
||||||
rendered?: boolean;
|
rendered?: boolean;
|
||||||
chunkType?: ChunkType;
|
chunkType?: ChunkType;
|
||||||
@ -57,7 +56,7 @@ export function generateBundleStats(info: {
|
|||||||
.map((f) => path.basename(f))
|
.map((f) => path.basename(f))
|
||||||
.join(', ') ?? '';
|
.join(', ') ?? '';
|
||||||
const names = info.names?.length ? info.names.join(', ') : '-';
|
const names = info.names?.length ? info.names.join(', ') : '-';
|
||||||
const initial = !!(info.entry || info.initial);
|
const initial = !!info.initial;
|
||||||
const chunkType = info.chunkType || 'unknown';
|
const chunkType = info.chunkType || 'unknown';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user