Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/angular/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"parse5-html-rewriting-stream": "8.0.1",
"picomatch": "4.0.4",
"piscina": "5.2.0",
"rollup": "4.62.0",
"rolldown": "1.1.1",
"sass": "1.101.0",
"semver": "7.8.4",
"source-map-support": "0.5.21",
Expand All @@ -55,7 +55,7 @@
"less": "4.6.6",
"ng-packagr": "22.1.0-next.2",
"postcss": "8.5.15",
"rolldown": "1.1.1",
"rollup": "4.62.0",
"rxjs": "7.8.2",
"vitest": "4.1.9"
},
Expand All @@ -73,6 +73,7 @@
"less": "^4.2.0",
"ng-packagr": "0.0.0-NG-PACKAGR-PEER-DEP",
"postcss": "^8.4.0",
"rollup": "^4.0.0",
"tailwindcss": "^2.0.0 || ^3.0.0 || ^4.0.0",
"tslib": "^2.3.0",
"typescript": ">=6.0 <6.1",
Expand Down Expand Up @@ -112,6 +113,9 @@
"postcss": {
"optional": true
},
"rollup": {
"optional": true
},
"tailwindcss": {
"optional": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import type { Message, Metafile } from 'esbuild';
import assert from 'node:assert';
import { type Plugin, rollup } from 'rollup';
import type { Plugin } from 'rollup';
import { BundleContextResult } from '../../tools/esbuild/bundler-context';
import {
type BuildOutputFile,
Expand Down Expand Up @@ -306,6 +306,15 @@ export async function optimizeChunks(
});
optimizedOutput = result.output;
} else {
let rollup;
Comment thread
clydin marked this conversation as resolved.
try {
rollup = (await import('rollup')).rollup;
} catch {
throw new Error(
`Rollup is required when 'NG_BUILD_CHUNKS_ROLLDOWN' is set to false. ` +
`Please install 'rollup' manually (e.g. 'npm install rollup --save-dev') to use this fallback.`,
);
}
bundle = await rollup({
input: mainFile,
plugins: plugins as Plugin[],
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/build/src/utils/environment-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const allowMinify = debugOptimize.minify;
* Allows using Rolldown for chunk optimization instead of Rollup.
* This is useful for debugging and testing scenarios.
*/
export const useRolldownChunks = parseTristate(process.env['NG_BUILD_CHUNKS_ROLLDOWN']) ?? false;
export const useRolldownChunks = parseTristate(process.env['NG_BUILD_CHUNKS_ROLLDOWN']) ?? true;

/**
* Some environments, like CircleCI which use Docker report a number of CPUs by the host and not the count of available.
Expand Down
48 changes: 24 additions & 24 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions tests/e2e/tests/build/chunk-optimizer-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,20 @@ export default async function () {
`Expected build with threshold 4 and 3 chunks to NOT be optimized. Thresh 4: ${jsFiles3Thresh4.length}, Unoptimized: ${jsFiles3Unopt.length}`,
);

// Case 4: Opt into Rolldown
await installPackage('rolldown@1.0.0-rc.12');
// Case 4: Opt back into Rollup (requires manual install since it's an optional peer dependency)
await installPackage('rollup@4.62.0');
try {
await execWithEnv('ng', ['build', '--output-hashing=none'], {
...process.env,
NG_BUILD_CHUNKS_ROLLDOWN: '1',
NG_BUILD_CHUNKS_ROLLDOWN: 'false',
NG_BUILD_OPTIMIZE_CHUNKS: 'true',
});
const filesRolldown = await readdir('dist/test-project/browser');
const jsFilesRolldown = filesRolldown.filter((f) => f.endsWith('.js'));
const filesRollup = await readdir('dist/test-project/browser');
const jsFilesRollup = filesRollup.filter((f) => f.endsWith('.js'));

assert.ok(jsFilesRolldown.length > 0, 'Expected Rolldown build to produce output files.');
assert.ok(jsFilesRollup.length > 0, 'Expected Rollup build to produce output files.');
} finally {
// Clean up
await uninstallPackage('rolldown');
await uninstallPackage('rollup');
}
}
Loading