Skip to content

Commit 254817a

Browse files
committed
refactor(@angular/build): use rolldown for experimental chunk optimization
Replaces rollup with rolldown for the experimental chunk optimization feature. This change is expected to improve performance of this feature. One relevant change to the output with this switch is that an ASCII only output does not currently appear possible with rolldown. As a result, the output with this experimental feature enabled will be UTF-8 instead.
1 parent 5d085ee commit 254817a

File tree

7 files changed

+217
-11
lines changed

7 files changed

+217
-11
lines changed

packages/angular/build/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ ts_project(
111111
":node_modules/picomatch",
112112
":node_modules/piscina",
113113
":node_modules/postcss",
114+
":node_modules/rolldown",
114115
":node_modules/sass",
115116
":node_modules/source-map-support",
116117
":node_modules/tinyglobby",
@@ -135,7 +136,6 @@ ts_project(
135136
"//:node_modules/esbuild",
136137
"//:node_modules/esbuild-wasm",
137138
"//:node_modules/karma",
138-
"//:node_modules/rollup",
139139
"//:node_modules/semver",
140140
"//:node_modules/tslib",
141141
"//:node_modules/typescript",

packages/angular/build/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"parse5-html-rewriting-stream": "8.0.0",
3838
"picomatch": "4.0.3",
3939
"piscina": "5.1.3",
40-
"rollup": "4.45.1",
40+
"rolldown": "1.0.0-beta.29",
4141
"sass": "1.89.2",
4242
"semver": "7.7.2",
4343
"source-map-support": "0.5.21",

packages/angular/build/src/builders/application/chunk-optimizer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import assert from 'node:assert';
10-
import { rollup } from 'rollup';
10+
import { rolldown } from 'rolldown';
1111
import {
1212
BuildOutputFile,
1313
BuildOutputFileType,
@@ -65,7 +65,7 @@ export async function optimizeChunks(
6565
let bundle;
6666
let optimizedOutput;
6767
try {
68-
bundle = await rollup({
68+
bundle = await rolldown({
6969
input: mainFile,
7070
plugins: [
7171
{
@@ -101,7 +101,7 @@ export async function optimizeChunks(
101101
});
102102

103103
const result = await bundle.generate({
104-
compact: true,
104+
minify: { mangle: false, compress: false, removeWhitespace: true },
105105
sourcemap,
106106
chunkFileNames: (chunkInfo) => `${chunkInfo.name.replace(/-[a-zA-Z0-9]{8}$/, '')}-[hash].js`,
107107
});

packages/angular/build/src/tools/vite/plugins/ssr-transform-plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import remapping, { SourceMapInput } from '@ampproject/remapping';
10-
import type { SourceDescription } from 'rollup';
1110
import type { Plugin } from 'vite';
1211
import { loadEsmModule } from '../../../utils/load-esm';
1312

@@ -28,7 +27,8 @@ export async function createAngularSsrTransformPlugin(workspaceRoot: string): Pr
2827

2928
return {
3029
code,
31-
map: remappedMap as SourceDescription['map'],
30+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
31+
map: remappedMap as any,
3232
};
3333
},
3434
};

pnpm-lock.yaml

Lines changed: 208 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/legacy-cli/e2e.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ WEBPACK_IGNORE_TESTS = [
5353
"tests/build/wasm-esm.js",
5454
"tests/build/auto-csp*",
5555
"tests/build/incremental-watch.js",
56+
"tests/build/chunk-optimizer.js",
5657
]
5758

5859
def _to_glob(patterns):

0 commit comments

Comments
 (0)