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
2 changes: 1 addition & 1 deletion integration/angular_cli/e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es2018",
"target": "es2019",
"types": [
"jasmine",
"node"
Expand Down
2 changes: 1 addition & 1 deletion integration/angular_cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2015",
"target": "es2017",
"module": "es2020",
"typeRoots": [
"node_modules/@types"
Expand Down
8 changes: 0 additions & 8 deletions packages/angular_devkit/build_angular/src/browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,6 @@ export function buildWebpackBrowser(
const buildBrowserFeatures = new BuildBrowserFeatures(sysProjectRoot);
const isDifferentialLoadingNeeded = buildBrowserFeatures.isDifferentialLoadingNeeded(target);

if (target > ScriptTarget.ES2015 && isDifferentialLoadingNeeded) {
context.logger.warn(tags.stripIndent`
Warning: Using differential loading with targets ES5 and ES2016 or higher may
cause problems. Browsers with support for ES2015 will load the ES2016+ scripts
referenced with script[type="module"] but they may not support ES2016+ syntax.
`);
}

checkInternetExplorerSupport(buildBrowserFeatures.supportedBrowsers, context.logger);

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Browser Builder allow js', () => {

host.replaceInFile(
'tsconfig.json',
'"target": "es2015"',
'"target": "es2017"',
'"target": "es5", "allowJs": true',
);

Expand All @@ -56,7 +56,7 @@ describe('Browser Builder allow js', () => {

host.replaceInFile(
'tsconfig.json',
'"target": "es2015"',
'"target": "es2017"',
'"target": "es5", "allowJs": true',
);

Expand All @@ -83,7 +83,7 @@ describe('Browser Builder allow js', () => {

host.replaceInFile(
'tsconfig.json',
'"target": "es2015"',
'"target": "es2017"',
'"target": "es5", "allowJs": true',
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Browser Builder browser support', () => {
architect = (await createArchitect(host.root())).architect;

// target ES5 to disable differential loading which is not needed for the tests
host.replaceInFile('tsconfig.json', '"target": "es2015"', '"target": "es5"');
host.replaceInFile('tsconfig.json', '"target": "es2017"', '"target": "es5"');
});
afterEach(async () => host.restore().toPromise());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,63 +34,23 @@ describe('Browser Builder with differential loading', () => {
'favicon.ico',
'index.html',

'main-es2015.js',
'main-es2015.js.map',
'main-es2017.js',
'main-es2017.js.map',
'main-es5.js',
'main-es5.js.map',

'polyfills-es2015.js',
'polyfills-es2015.js.map',
'polyfills-es2017.js',
'polyfills-es2017.js.map',
'polyfills-es5.js',
'polyfills-es5.js.map',

'runtime-es2015.js',
'runtime-es2015.js.map',
'runtime-es2017.js',
'runtime-es2017.js.map',
'runtime-es5.js',
'runtime-es5.js.map',

'vendor-es2015.js',
'vendor-es2015.js.map',
'vendor-es5.js',
'vendor-es5.js.map',

'styles.css',
'styles.css.map',
] as PathFragment[];

expect(Object.keys(files)).toEqual(jasmine.arrayWithExactContents(expectedOutputs));
});

it('emits all the neccessary files for target of ES2016', async () => {
host.replaceInFile(
'tsconfig.json',
'"target": "es2015",',
`"target": "es2016",`,
);

const { files } = await browserBuild(architect, host, target);

const expectedOutputs = [
'favicon.ico',
'index.html',

'main-es2016.js',
'main-es2016.js.map',
'main-es5.js',
'main-es5.js.map',

'polyfills-es2016.js',
'polyfills-es2016.js.map',
'polyfills-es5.js',
'polyfills-es5.js.map',

'runtime-es2016.js',
'runtime-es2016.js.map',
'runtime-es5.js',
'runtime-es5.js.map',

'vendor-es2016.js',
'vendor-es2016.js.map',
'vendor-es2017.js',
'vendor-es2017.js.map',
'vendor-es5.js',
'vendor-es5.js.map',

Expand All @@ -104,7 +64,7 @@ describe('Browser Builder with differential loading', () => {
it('emits all the neccessary files for target of ESNext', async () => {
host.replaceInFile(
'tsconfig.json',
'"target": "es2015",',
'"target": "es2017",',
`"target": "esnext",`,
);

Expand Down Expand Up @@ -148,17 +108,17 @@ describe('Browser Builder with differential loading', () => {
'favicon.ico',
'index.html',

'main-es2015.js',
'main-es2015.js.map',
'main-es2017.js',
'main-es2017.js.map',

'polyfills-es2015.js',
'polyfills-es2015.js.map',
'polyfills-es2017.js',
'polyfills-es2017.js.map',

'runtime-es2015.js',
'runtime-es2015.js.map',
'runtime-es2017.js',
'runtime-es2017.js.map',

'vendor-es2015.js',
'vendor-es2015.js.map',
'vendor-es2017.js',
'vendor-es2017.js.map',

'styles.css',
'styles.css.map',
Expand All @@ -173,21 +133,21 @@ describe('Browser Builder with differential loading', () => {
vendorChunk: false,
});
expect(await files['main-es5.js']).not.toContain('const ');
expect(await files['main-es2015.js']).toContain('const ');
expect(await files['main-es2017.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 \(\) \{/);
expect(await files['main-es2017.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/plugins/zone-legacy');
expect(await files['polyfills-es5.js']).toContain('registerElementPatch');
expect(await files['polyfills-es2015.js']).not.toContain('zone.js/plugins/zone-legacy');
expect(await files['polyfills-es2015.js']).not.toContain('registerElementPatch');
expect(await files['polyfills-es2017.js']).not.toContain('zone.js/plugins/zone-legacy');
expect(await files['polyfills-es2017.js']).not.toContain('registerElementPatch');
});

it('adds `type="module"` when differential loading is needed', async () => {
Expand All @@ -200,10 +160,10 @@ describe('Browser Builder with differential loading', () => {

const { files } = await browserBuild(architect, host, target, { watch: true });
expect(await files['index.html']).toContain(
'<script src="runtime-es2015.js" type="module"></script>' +
'<script src="polyfills-es2015.js" type="module"></script>' +
'<script src="vendor-es2015.js" type="module"></script>' +
'<script src="main-es2015.js" type="module"></script>',
'<script src="runtime-es2017.js" type="module"></script>' +
'<script src="polyfills-es2017.js" type="module"></script>' +
'<script src="vendor-es2017.js" type="module"></script>' +
'<script src="main-es2017.js" type="module"></script>',
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ describe('Browser Builder lazy modules', () => {
'src/lazy-module.ts': 'export const value = 42;',
'src/main.ts': `import('./lazy-module');`,
});
// Using `import()` in TS require targetting `esnext` modules.
host.replaceInFile('src/tsconfig.app.json', `"module": "es2015"`, `"module": "esnext"`);

const { files } = await browserBuild(architect, host, target);
expect(files['lazy-module.js']).not.toBeUndefined();
Expand All @@ -146,7 +144,6 @@ describe('Browser Builder lazy modules', () => {
import(/*webpackChunkName: '[request]'*/'./lazy-' + lazyFileName);
`,
});
host.replaceInFile('src/tsconfig.app.json', `"module": "es2015"`, `"module": "esnext"`);

const { files } = await browserBuild(architect, host, target);
expect(files['lazy-module.js']).not.toBeUndefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ describe('Browser Builder optimization level', () => {
expect(await files['main.js']).not.toContain('AppComponent');
});

it('tsconfig target changes optimizations to use ES2015', async () => {
host.replaceInFile('tsconfig.json', '"target": "es5"', '"target": "es2015"');
it('tsconfig target changes optimizations to use es2017', async () => {
host.replaceInFile('tsconfig.json', '"target": "es5"', '"target": "es2017"');

const overrides = { optimization: true };
const { files } = await browserBuild(architect, host, target, overrides);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Browser Builder resolve json module', () => {

host.replaceInFile(
'tsconfig.json',
'"target": "es2015"',
'"target": "es2017"',
'"target": "es5", "resolveJsonModule": true',
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ describe('Browser Builder scripts array', () => {
'lazy-script.js': 'lazy-script',
'renamed-script.js': 'pre-rename-script',
'renamed-lazy-script.js': 'pre-rename-lazy-script',
'main-es2015.js': 'input-script',
'index.html': '<script src="runtime-es2015.js" type="module"></script>'
+ '<script src="polyfills-es2015.js" type="module"></script>'
'main-es2017.js': 'input-script',
'index.html': '<script src="runtime-es2017.js" type="module"></script>'
+ '<script src="polyfills-es2017.js" type="module"></script>'
+ '<script src="scripts.js" defer></script>'
+ '<script src="renamed-script.js" defer></script>'
+ '<script src="vendor-es2015.js" type="module"></script>'
+ '<script src="main-es2015.js" type="module"></script>',
+ '<script src="vendor-es2017.js" type="module"></script>'
+ '<script src="main-es2017.js" type="module"></script>',
};

host.writeMultipleFiles(scripts);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ describe('Browser Builder styles', () => {
});

// Set to target to ES5 to avoid differential loading and unnecessary testing time
host.replaceInFile('tsconfig.json', '"target": "es2015"', '"target": "es5"');
host.replaceInFile('tsconfig.json', '"target": "es2017"', '"target": "es5"');

const overrides = { extractCss: true, optimization: false };
const { files } = await browserBuild(architect, host, target, overrides);
Expand Down Expand Up @@ -346,7 +346,7 @@ describe('Browser Builder styles', () => {
});

// Set target to ES5 to avoid differential loading and unnecessary testing time
host.replaceInFile('tsconfig.json', '"target": "es2015"', '"target": "es5"');
host.replaceInFile('tsconfig.json', '"target": "es2017"', '"target": "es5"');

const overrides = { extractCss: true, optimization: true, styles: ['src/styles.scss'] };
const { files } = await browserBuild(architect, host, target, overrides);
Expand Down
10 changes: 0 additions & 10 deletions packages/angular_devkit/build_angular/src/karma/works_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ describe('Karma Builder', () => {
await run.stop();
});

it('supports ES2015 target', async () => {
host.replaceInFile('tsconfig.json', '"target": "es5"', '"target": "es2015"');

const run = await architect.scheduleTarget(karmaTargetSpec);

await expectAsync(run.result).toBeResolvedTo(jasmine.objectContaining({ success: true }));

await run.stop();
});

it('generates and uses global styles', async () => {
host.writeMultipleFiles({
'src/styles.css': 'p {display: none}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class BuildBrowserFeatures {

/**
* True, when one or more browsers requires ES5
* support and the scirpt target is ES2015 or greater.
* support and the script target is ES2015 or greater.
*/
isDifferentialLoadingNeeded(scriptTarget: ts.ScriptTarget): boolean {
const es6TargetOrLater = scriptTarget > ts.ScriptTarget.ES5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ describe('BuildBrowserFeatures', () => {
afterEach(async () => host.restore().toPromise());

describe('isDifferentialLoadingNeeded', () => {
it('should be true for IE 9-11 and ES2015', () => {
it('should be true for IE 9-11 and ES2017', () => {
host.writeMultipleFiles({
'.browserslistrc': 'IE 9-11',
});

const buildBrowserFeatures = new BuildBrowserFeatures(workspaceRootSysPath);
expect(buildBrowserFeatures.isDifferentialLoadingNeeded(ScriptTarget.ES2015)).toBe(true);
expect(buildBrowserFeatures.isDifferentialLoadingNeeded(ScriptTarget.ES2017)).toBe(true);
});

it('should be false for Chrome and ES2015', () => {
it('should be false for Chrome and ES2017', () => {
host.writeMultipleFiles({
'.browserslistrc': 'last 1 chrome version',
});

const buildBrowserFeatures = new BuildBrowserFeatures(workspaceRootSysPath);
expect(buildBrowserFeatures.isDifferentialLoadingNeeded(ScriptTarget.ES2015)).toBe(false);
expect(buildBrowserFeatures.isDifferentialLoadingNeeded(ScriptTarget.ES2017)).toBe(false);
});

it('detects no need for differential loading for target is ES5', () => {
Expand All @@ -52,13 +52,13 @@ describe('BuildBrowserFeatures', () => {
expect(buildBrowserFeatures.isDifferentialLoadingNeeded(ScriptTarget.ES5)).toBe(false);
});

it('should be false for Safari 10.1 when target is ES2015', () => {
it('should be false for Safari 10.1 when target is ES2017', () => {
host.writeMultipleFiles({
'.browserslistrc': 'Safari 10.1',
});

const buildBrowserFeatures = new BuildBrowserFeatures(workspaceRootSysPath);
expect(buildBrowserFeatures.isDifferentialLoadingNeeded(ScriptTarget.ES2015)).toBe(false);
expect(buildBrowserFeatures.isDifferentialLoadingNeeded(ScriptTarget.ES2017)).toBe(false);
});
});

Expand Down
Loading