chore(angular): ensure e2es with rspack builds are minimized (#31294)

## Current Behavior
The e2e tests running Angular Rspack are not having their builds
minimized currently.

## Expected Behavior
Ensure `NODE_ENV=production` is set when calling the build commands
This commit is contained in:
Colum Ferry 2025-05-21 14:22:47 +01:00 committed by GitHub
parent 43a20e2ecc
commit 2ec086a4b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 22 deletions

View File

@ -162,13 +162,9 @@ describe('Convert Angular Webpack Project to Rspack', () => {
it('should convert an Angular Webpack project to Rspack', async () => { it('should convert an Angular Webpack project to Rspack', async () => {
runCLI(`generate @nx/angular:convert-to-rspack --project=${app1}`); runCLI(`generate @nx/angular:convert-to-rspack --project=${app1}`);
const rspackConfigFileContents = readFile(join(app1, 'rspack.config.ts')); const buildOutput = runCLI(`build ${app1}`, {
const updatedConfigFileContents = rspackConfigFileContents.replace( env: { NODE_ENV: 'production' },
`maximumError: '1mb'`, });
`maximumError: '3mb'`
);
updateFile(join(app1, 'rspack.config.ts'), updatedConfigFileContents);
const buildOutput = runCLI(`build ${app1}`);
expect(buildOutput).toContain('rspack build'); expect(buildOutput).toContain('rspack build');
expect(buildOutput).toContain('Successfully ran target build for project'); expect(buildOutput).toContain('Successfully ran target build for project');
}); });

View File

@ -46,7 +46,7 @@ describe('Angular Module Federation', () => {
let rspackConfigFileContents = readFile(join(hostApp, 'rspack.config.ts')); let rspackConfigFileContents = readFile(join(hostApp, 'rspack.config.ts'));
let updatedConfigFileContents = rspackConfigFileContents.replace( let updatedConfigFileContents = rspackConfigFileContents.replace(
`maximumError: '1mb'`, `maximumError: '1mb'`,
`maximumError: '11mb'` `maximumError: '3mb'`
); );
updateFile(join(hostApp, 'rspack.config.ts'), updatedConfigFileContents); updateFile(join(hostApp, 'rspack.config.ts'), updatedConfigFileContents);
@ -57,7 +57,7 @@ describe('Angular Module Federation', () => {
rspackConfigFileContents = readFile(join(remoteApp1, 'rspack.config.ts')); rspackConfigFileContents = readFile(join(remoteApp1, 'rspack.config.ts'));
updatedConfigFileContents = rspackConfigFileContents.replace( updatedConfigFileContents = rspackConfigFileContents.replace(
`maximumError: '1mb'`, `maximumError: '1mb'`,
`maximumError: '11mb'` `maximumError: '3mb'`
); );
updateFile(join(remoteApp1, 'rspack.config.ts'), updatedConfigFileContents); updateFile(join(remoteApp1, 'rspack.config.ts'), updatedConfigFileContents);
@ -68,7 +68,9 @@ describe('Angular Module Federation', () => {
); );
// check default generated host is built successfully // check default generated host is built successfully
const buildOutput = runCLI(`build ${hostApp}`); const buildOutput = runCLI(`build ${hostApp}`, {
env: { NODE_ENV: 'production' },
});
expect(buildOutput).toContain('Successfully ran target build'); expect(buildOutput).toContain('Successfully ran target build');
// generate a shared lib with a seconary entry point // generate a shared lib with a seconary entry point

View File

@ -154,18 +154,9 @@ describe('Angular Projects', () => {
runCLI( runCLI(
`generate @nx/angular:app my-dir/${app} --bundler=rspack --no-interactive` `generate @nx/angular:app my-dir/${app} --bundler=rspack --no-interactive`
); );
const rspackConfigFileContents = readFile( runCLI(`build ${app}`, {
join('my-dir', app, 'rspack.config.ts') env: { NODE_ENV: 'production' },
); });
const updatedConfigFileContents = rspackConfigFileContents.replace(
`maximumError: '1mb'`,
`maximumError: '3mb'`
);
updateFile(
join('my-dir', app, 'rspack.config.ts'),
updatedConfigFileContents
);
runCLI(`build ${app}`);
if (runE2ETests()) { if (runE2ETests()) {
expect(() => runCLI(`e2e ${app}-e2e`)).not.toThrow(); expect(() => runCLI(`e2e ${app}-e2e`)).not.toThrow();