Skip to content
Merged
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
7 changes: 1 addition & 6 deletions packages/angular/cli/commands/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@
}
},
"configuration": {
"description": "One or more named builder configurations as a comma-separated list as specified in the \"configurations\" section of angular.json.\nThe builder uses the named configurations to run the given target.\nFor more information, see https://angular.io/guide/workspace-config#alternate-build-configurations.\nSetting this explicitly overrides the \"--prod\" flag.",
"description": "One or more named builder configurations as a comma-separated list as specified in the \"configurations\" section of angular.json.\nThe builder uses the named configurations to run the given target.\nFor more information, see https://angular.io/guide/workspace-config#alternate-build-configurations.",
"type": "string",
"aliases": ["c"]
},
"prod": {
"description": "Shorthand for \"--configuration=production\".\nSet the build configuration to the production target.\nBy default, the production target is set up in the workspace configuration such that all builds make use of bundling, limited tree-shaking, and also limited dead code elimination.",
"type": "boolean",
"x-deprecated": "Use `--configuration production` instead."
}
}
},
Expand Down
15 changes: 0 additions & 15 deletions packages/angular/cli/models/architect-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,21 +422,6 @@ export abstract class ArchitectCommand<
} else {
project = commandOptions.project;
target = this.target;
if (commandOptions.prod) {
const defaultConfig =
project &&
target &&
this.workspace?.projects.get(project)?.targets.get(target)?.defaultConfiguration;

this.logger.warn(
defaultConfig === 'production'
? 'Option "--prod" is deprecated: No need to use this option as this builder defaults to configuration "production".'
: 'Option "--prod" is deprecated: Use "--configuration production" instead.',
);
// The --prod flag will always be the first configuration, available to be overwritten
// by following configurations.
configuration = 'production';
}
if (commandOptions.configuration) {
configuration = `${configuration ? `${configuration},` : ''}${
commandOptions.configuration
Expand Down
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/assets/9.0-project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Run `ng generate component component-name` to generate a new component. You can

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.

## Running unit tests

Expand Down
87 changes: 51 additions & 36 deletions tests/legacy-cli/e2e/tests/build/lazy-load-syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,64 +16,79 @@ export default async function () {

// Add app routing.
// This is done automatically on a new app with --routing.
await writeFile(appRoutingModulePath, `
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
await writeFile(
appRoutingModulePath,
`
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [];
const routes: Routes = [];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
`);
await prependToFile('src/app/app.module.ts',
`import { AppRoutingModule } from './app-routing.module';`);
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
`,
);
Comment thread
alan-agius4 marked this conversation as resolved.
await prependToFile(
'src/app/app.module.ts',
`import { AppRoutingModule } from './app-routing.module';`,
);
await replaceInFile('src/app/app.module.ts', `imports: [`, `imports: [ AppRoutingModule,`);
await appendToFile('src/app/app.component.html', '<router-outlet></router-outlet>');

const originalAppRoutingModule = await readFile(appRoutingModulePath);
// helper to replace loadChildren
const replaceLoadChildren = async (route: string) => {
const content = originalAppRoutingModule.replace('const routes: Routes = [];', `
const routes: Routes = [{ path: 'lazy', loadChildren: ${route} }];
`);
const content = originalAppRoutingModule.replace(
'const routes: Routes = [];',
`
const routes: Routes = [{ path: 'lazy', loadChildren: ${route} }];
`,
);

return writeFile(appRoutingModulePath, content);
};

// Add lazy route.
await ng('generate', 'module', 'lazy', '--routing');
await ng('generate', 'component', 'lazy/lazy-comp');
await replaceInFile('src/app/lazy/lazy-routing.module.ts', 'const routes: Routes = [];', `
import { LazyCompComponent } from './lazy-comp/lazy-comp.component';
const routes: Routes = [{ path: '', component: LazyCompComponent }];
`);
await replaceInFile(
'src/app/lazy/lazy-routing.module.ts',
'const routes: Routes = [];',
`
import { LazyCompComponent } from './lazy-comp/lazy-comp.component';
const routes: Routes = [{ path: '', component: LazyCompComponent }];
`,
);

// Add lazy route e2e
await writeFile('e2e/src/app.e2e-spec.ts', `
import { browser, logging, element, by } from 'protractor';
await writeFile(
'e2e/src/app.e2e-spec.ts',
`
import { browser, logging, element, by } from 'protractor';

describe('workspace-project App', () => {
it('should display lazy route', async () => {
await browser.get(browser.baseUrl + '/lazy');
expect(await element(by.css('app-lazy-comp p')).getText()).toEqual('lazy-comp works!');
});
describe('workspace-project App', () => {
it('should display lazy route', async () => {
await browser.get(browser.baseUrl + '/lazy');
expect(await element(by.css('app-lazy-comp p')).getText()).toEqual('lazy-comp works!');
});

afterEach(async () => {
// Assert that there are no errors emitted from the browser
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
expect(logs).not.toContain(jasmine.objectContaining({
level: logging.Level.SEVERE,
}));
afterEach(async () => {
// Assert that there are no errors emitted from the browser
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
expect(logs).not.toContain(jasmine.objectContaining({
level: logging.Level.SEVERE,
}));
});
});
});
`);
`,
);

// Convert the default config to use JIT and prod to just do AOT.
// This way we can use `ng e2e` to test JIT and `ng e2e --prod` to test AOT.
await updateJsonFile('angular.json', json => {
// This way we can use `ng e2e` to test JIT and `ng e2e --configuration=production` to test AOT.
await updateJsonFile('angular.json', (json) => {
const buildTarget = json['projects'][projectName]['architect']['build'];
buildTarget['options']['aot'] = true;
buildTarget['configurations']['development']['aot'] = false;
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy-cli/e2e/tests/build/material.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { isPrereleaseCli, updateJsonFile } from '../../utils/project';
const snapshots = require('../../ng-snapshot/package.json');

export default async function () {
const tag = await isPrereleaseCli() ? '@next' : '';
const tag = (await isPrereleaseCli()) ? '@next' : '';
await ng('add', `@angular/material${tag}`, '--skip-confirmation');

const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
Expand Down Expand Up @@ -72,5 +72,5 @@ export default async function () {
`,
);

await ng('e2e', '--prod');
await ng('e2e', '--configuration=production');
}
10 changes: 7 additions & 3 deletions tests/legacy-cli/e2e/tests/build/rebuild-replacements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@ import { wait } from '../../utils/utils';

const webpackGoodRegEx = / Compiled successfully./;

export default async function() {
export default async function () {
if (process.platform.startsWith('win')) {
return;
}

let error;
try {
await execAndWaitForOutputToMatch('ng', ['serve', '--prod'], webpackGoodRegEx);
await execAndWaitForOutputToMatch(
'ng',
['serve', '--configuration=production'],
webpackGoodRegEx,
);

await wait(4000);

// Should trigger a rebuild.
await appendToFile('src/environments/environment.prod.ts', `console.log('PROD');`);
await waitForAnyProcessOutputToMatch(webpackGoodRegEx, 45000);
Expand Down
Loading