Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: angular/angular-cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v10.0.2
Choose a base ref
...
head repository: angular/angular-cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v10.0.3
Choose a head ref
  • 9 commits
  • 16 files changed
  • 5 contributors

Commits on Jul 9, 2020

  1. test(@schematics/schematics): run npm install from local registry

    After a new tag is pushed, the schematic e2e test will attempt to
    install the latest version, but it incorrectly installs the version
    from the actual NPM registry instead of the local registry.
    kyliau authored and alan-agius4 committed Jul 9, 2020
    Copy the full SHA
    0f9f797 View commit details

Commits on Jul 13, 2020

  1. fix(@angular-devkit/build-angular): wrap ES5 differential loading bun…

    …dles
    
    This change ensures that classic (ES5) script's top-level function helpers do not get overwritten by other scripts top-level functions that happen to have the same name.  This is not an issue when using module script types because each module has its own scope.
    
    (cherry picked from commit bcb41e3)
    clydin committed Jul 13, 2020
    Copy the full SHA
    967a3db View commit details
  2. test(@angular-devkit/build-angular): increase rebuild debounce times

    CI performance variability can cause test flakes in rebuild tests due to the rebuilds taking longer than expected.  This change increases the 500ms debounce time for the web worker rebuild tests to 1000ms to mitigate these issues.
    
    (cherry picked from commit c75a48d)
    clydin committed Jul 13, 2020
    Copy the full SHA
    27c8d22 View commit details
  3. fix(@schematics/angular): don't add e2e tsconfig reference in solutio…

    …n tsconfig
    
    Since the tsconfig for e2e’s is named tsconfig.json there is no reason why it should be included in the solutions typescript configuration file.
    
    Closes #18190
    
    (cherry picked from commit cc87202)
    alan-agius4 authored and clydin committed Jul 13, 2020
    Copy the full SHA
    c11f76a View commit details
  4. style: format ngsw-config

    (cherry picked from commit 50ca94a)
    alan-agius4 authored and clydin committed Jul 13, 2020
    Copy the full SHA
    3713787 View commit details
  5. fix(@angular-devkit/build-angular): don't emit empty warnings

    Closes #18231
    
    (cherry picked from commit 0b20676)
    alan-agius4 authored and clydin committed Jul 13, 2020
    Copy the full SHA
    e3a94cb View commit details

Commits on Jul 15, 2020

  1. fix(@schematics/angular): consecutive blank lines in routing.module.ts

    Fixes: #18220
    (cherry picked from commit d4198e5)
    sacgrover authored and clydin committed Jul 15, 2020
    Copy the full SHA
    ea907d7 View commit details
  2. fix(@angular-devkit/build-angular): suppress warning for CommonJS tem…

    …plateUrl and styleUrl
    
    Currently, when users use either absolute paths, or path mappings in JIT mode, we issue a warning for templateUrl and styleUrl. With this change we suppress those warning.
    
    Closes: #18057
    (cherry picked from commit 2aedad9)
    alan-agius4 authored and clydin committed Jul 15, 2020
    Copy the full SHA
    fcfcd68 View commit details
  3. release: v10.0.3

    Keen Yee Liau committed Jul 15, 2020
    Copy the full SHA
    f1a7c10 View commit details
Original file line number Diff line number Diff line change
@@ -14,6 +14,8 @@ import { Compiler, compilation } from 'webpack';
const CommonJsRequireDependency = require('webpack/lib/dependencies/CommonJsRequireDependency');
const AMDDefineDependency = require('webpack/lib/dependencies/AMDDefineDependency');

const STYLES_TEMPLATE_URL_REGEXP = /\.(html|svg|css|sass|less|styl|scss)$/;

// The below is extended because there are not in the typings
interface WebpackModule extends compilation.Module {
name?: string;
@@ -23,6 +25,10 @@ interface WebpackModule extends compilation.Module {
userRequest?: string;
}

interface CommonJsRequireDependencyType {
request: string;
}

export interface CommonJsUsageWarnPluginOptions {
/** A list of CommonJS packages that are allowed to be used without a warning. */
allowedDepedencies?: string[];
@@ -61,7 +67,7 @@ export class CommonJsUsageWarnPlugin {
continue;
}

if (this.hasCommonJsDependencies(dependencies)) {
if (this.hasCommonJsDependencies(dependencies, true)) {
// Dependency is CommonsJS or AMD.

// Check if it's parent issuer is also a CommonJS dependency.
@@ -97,8 +103,23 @@ export class CommonJsUsageWarnPlugin {
});
}

private hasCommonJsDependencies(dependencies: unknown[]): boolean {
return dependencies.some(d => d instanceof CommonJsRequireDependency || d instanceof AMDDefineDependency);
private hasCommonJsDependencies(dependencies: unknown[], checkForStylesAndTemplatesCJS = false): boolean {
for (const dep of dependencies) {
if (dep instanceof CommonJsRequireDependency) {
if (checkForStylesAndTemplatesCJS && STYLES_TEMPLATE_URL_REGEXP.test((dep as CommonJsRequireDependencyType).request)) {
// Skip in case it's a template or stylesheet
continue;
}

return true;
}

if (dep instanceof AMDDefineDependency) {
return true;
}
}

return false;
}

private rawRequestToPackageName(rawRequest: string): string {
Original file line number Diff line number Diff line change
@@ -100,10 +100,11 @@ export function statsWarningsToString(json: any, statsConfig: any) {
}

return rs('\n' + warnings
.map((warning: any) => `${warning}`)
.filter((warning: string) => !ERRONEOUS_WARNINGS.some((erroneous) => erroneous.test(warning)))
.map((warning: string) => y(`WARNING in ${warning}`))
.join('\n\n'));
.filter(m => !!m)
.map((warning: any) => `${warning}`)
.filter((warning: string) => !ERRONEOUS_WARNINGS.some((erroneous) => erroneous.test(warning)))
.map((warning: string) => y(`WARNING in ${warning}`))
.join('\n\n'));
}

export function statsErrorsToString(json: any, statsConfig: any) {
@@ -115,7 +116,11 @@ export function statsErrorsToString(json: any, statsConfig: any) {
errors.push(...json.children.map((c: any) => c.errors));
}

return rs('\n' + errors.map((error: any) => r(`ERROR in ${error}`)).join('\n'));
return rs('\n' + errors
.filter(m => !!m)
.map((error: any) => r(`ERROR in ${error}`))
.join('\n\n')
);
}

export function statsHasErrors(json: any): boolean {
Original file line number Diff line number Diff line change
@@ -77,4 +77,24 @@ describe('Browser Builder commonjs warning', () => {
expect(logs.join()).not.toContain('WARNING');
await run.stop();
});

it('should not show warning in JIT for templateUrl and styleUrl when using paths', async () => {
host.replaceInFile('tsconfig.base.json', /"baseUrl": ".\/",/, `
"baseUrl": "./",
"paths": {
"@app/*": [
"src/app/*"
]
},
`);

host.replaceInFile('src/app/app.module.ts', './app.component', '@app/app.component');

const run = await architect.scheduleTarget(targetSpec, { aot: false }, { logger });
const output = await run.result;
expect(output.success).toBe(true);

expect(logs.join()).not.toContain('WARNING');
await run.stop();
});
});
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ import { Architect } from '@angular-devkit/architect';
import { PathFragment } from '@angular-devkit/core';
import { browserBuild, createArchitect, host } from '../../test-utils';

// tslint:disable-next-line: no-big-function
describe('Browser Builder with differential loading', () => {
const target = { project: 'app', target: 'build' };
let architect: Architect;
@@ -181,6 +182,12 @@ describe('Browser Builder with differential loading', () => {
expect(await files['main-es2015.js']).toContain('const ');
});

it('wraps ES5 scripts in an IIFE', async () => {
const { files } = await browserBuild(architect, host, target, { optimization: false });
expect(await files['main-es5.js']).toMatch(/^\(function \(\) \{/);
expect(await files['main-es2015.js']).not.toMatch(/^\(function \(\) \{/);
});

it('uses the right zone.js variant', async () => {
const { files } = await browserBuild(architect, host, target, { optimization: false });
expect(await files['polyfills-es5.js']).toContain('zone.js/dist/zone-legacy');
Original file line number Diff line number Diff line change
@@ -147,7 +147,7 @@ describe('Browser Builder Web Worker support', () => {
const { run } = await timer(1000).pipe(
switchMap(() => architect.scheduleTarget(target, overrides)),
switchMap(run => run.output.pipe(map(output => ({ run, output })))),
debounceTime(500),
debounceTime(1000),
tap(({ output }) => expect(output.success).toBe(true, 'build should succeed')),
tap(() => {
switch (phase) {
Original file line number Diff line number Diff line change
@@ -157,7 +157,10 @@ export async function process(options: ProcessBundleOptions): Promise<ProcessBun
exclude: ['transform-typeof-symbol'],
},
]],
plugins: options.replacements ? [createReplacePlugin(options.replacements)] : [],
plugins: [
createIifeWrapperPlugin(),
...(options.replacements ? [createReplacePlugin(options.replacements)] : []),
],
minified: allowMinify && !!options.optimize,
compact: !shouldBeautify && !!options.optimize,
sourceMaps: !!sourceMap,
@@ -509,6 +512,36 @@ function createReplacePlugin(replacements: [string, string][]): PluginObj {
};
}

function createIifeWrapperPlugin(): PluginObj {
return {
visitor: {
Program: {
exit(path: NodePath<types.Program>) {
// Save existing body and directives
const { body, directives } = path.node;

// Clear out body and directives for wrapper
path.node.body = [];
path.node.directives = [];

// Create the wrapper - "(function() { ... })();"
const wrapper = types.expressionStatement(
types.callExpression(
types.parenthesizedExpression(
types.functionExpression(undefined, [], types.blockStatement(body, directives)),
),
[],
),
);

// Insert the wrapper
path.pushContainer('body', wrapper);
},
},
},
};
}

const USE_LOCALIZE_PLUGINS = false;

export async function createI18nPlugins(
1 change: 0 additions & 1 deletion packages/schematics/angular/application/index_spec.ts
Original file line number Diff line number Diff line change
@@ -88,7 +88,6 @@ describe('Application Schematic', () => {
expect(references).toEqual([
{ path: './projects/foo/tsconfig.app.json' },
{ path: './projects/foo/tsconfig.spec.json' },
{ path: './projects/foo/e2e/tsconfig.json' },
]);
});

5 changes: 1 addition & 4 deletions packages/schematics/angular/e2e/index.ts
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ import {
url,
} from '@angular-devkit/schematics';
import { relativePathToWorkspaceRoot } from '../utility/paths';
import { addTsConfigProjectReferences, verifyBaseTsConfigExists } from '../utility/tsconfig';
import { verifyBaseTsConfigExists } from '../utility/tsconfig';
import { getWorkspace, updateWorkspace } from '../utility/workspace';
import { Builders } from '../utility/workspace-models';
import { Schema as E2eOptions } from './schema';
@@ -68,9 +68,6 @@ export default function (options: E2eOptions): Rule {
}),
move(root),
])),
addTsConfigProjectReferences([
e2eTsConfig,
]),
]);
};
}
13 changes: 0 additions & 13 deletions packages/schematics/angular/e2e/index_spec.ts
Original file line number Diff line number Diff line change
@@ -82,19 +82,6 @@ describe('Application Schematic', () => {
expect(content).toMatch(/🌮-🌯/);
});

it('should add reference in solution style tsconfig', async () => {
const tree = await schematicRunner.runSchematicAsync('e2e', defaultOptions, applicationTree)
.toPromise();

// tslint:disable-next-line:no-any
const { references } = parseJson(tree.readContent('/tsconfig.json').toString(), JsonParseMode.Loose) as any;
expect(references).toEqual([
{ path: './projects/foo/tsconfig.app.json' },
{ path: './projects/foo/tsconfig.spec.json' },
{ path: './projects/foo/e2e/tsconfig.json' },
]);
});

describe('workspace config', () => {
it('should add e2e targets for the app', async () => {
const tree = await schematicRunner.runSchematicAsync('e2e', defaultOptions, applicationTree)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
<% if (lazyRoute) { %>
import { Routes, RouterModule } from '@angular/router';<% if (lazyRoute) { %>

import { <%= classify(name) %>Component } from './<%= dasherize(name) %>.component';<% } %>

const routes: Routes = [<% if (lazyRoute) { %>{ path: '', component: <%= classify(name) %>Component }<% } %>];
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@
"/*.js"
]
}
}, {
},
{
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
2 changes: 0 additions & 2 deletions packages/schematics/angular/universal/index_spec.ts
Original file line number Diff line number Diff line change
@@ -273,10 +273,8 @@ describe('Universal Schematic', () => {
expect(references).toEqual([
{ path: './tsconfig.app.json' },
{ path: './tsconfig.spec.json' },
{ path: './e2e/tsconfig.json' },
{ path: './projects/bar/tsconfig.app.json' },
{ path: './projects/bar/tsconfig.spec.json' },
{ path: './projects/bar/e2e/tsconfig.json' },
{ path: './tsconfig.server.json' },
]);
});
8 changes: 4 additions & 4 deletions packages/schematics/angular/utility/latest-versions.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

export const latestVersions = {
// These versions should be kept up to date with latest Angular peer dependencies.
Angular: '~10.0.3',
Angular: '~10.0.4',
RxJs: '~6.5.5',
ZoneJs: '~0.10.3',
TypeScript: '~3.9.5',
@@ -18,9 +18,9 @@ export const latestVersions = {
// For our e2e tests, these versions must match the latest tag present on the branch.
// During RC periods they will not match the latest RC until there's a new git tag, and
// should not be updated.
DevkitBuildAngular: '~0.1000.2',
DevkitBuildNgPackagr: '~0.1000.2',
DevkitBuildWebpack: '~0.1000.2',
DevkitBuildAngular: '~0.1000.3',
DevkitBuildNgPackagr: '~0.1000.3',
DevkitBuildWebpack: '~0.1000.3',

ngPackagr: '^10.0.0',
};
1 change: 0 additions & 1 deletion packages/schematics/angular/web-worker/index_spec.ts
Original file line number Diff line number Diff line change
@@ -162,7 +162,6 @@ describe('Web Worker Schematic', () => {
expect(references).toEqual([
{ path: './projects/bar/tsconfig.app.json' },
{ path: './projects/bar/tsconfig.spec.json' },
{ path: './projects/bar/e2e/tsconfig.json' },
{ path: './projects/bar/tsconfig.worker.json' },
]);
});
4 changes: 3 additions & 1 deletion tests/legacy-cli/e2e/tests/schematics_cli/blank-test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as fs from 'fs';
import * as path from 'path';
import { getGlobalVariable } from '../../utils/env';
import { exec, silentNpm } from '../../utils/process';
@@ -10,11 +11,12 @@ export default async function () {
return;
}

fs.writeFileSync('.npmrc', 'registry = http://localhost:4873', 'utf8');

await silentNpm(
'install',
'-g',
'@angular-devkit/schematics-cli',
'--registry=http://localhost:4873',
);
await exec(process.platform.startsWith('win') ? 'where' : 'which', 'schematics');

4 changes: 3 additions & 1 deletion tests/legacy-cli/e2e/tests/schematics_cli/schematic-test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as fs from 'fs';
import * as path from 'path';
import { getGlobalVariable } from '../../utils/env';
import { exec, silentNpm } from '../../utils/process';
@@ -10,11 +11,12 @@ export default async function () {
return;
}

fs.writeFileSync('.npmrc', 'registry = http://localhost:4873', 'utf8');

await silentNpm(
'install',
'-g',
'@angular-devkit/schematics-cli',
'--registry=http://localhost:4873',
);
await exec(process.platform.startsWith('win') ? 'where' : 'which', 'schematics');