Skip to content

feat(@angular-devkit/build-angular): remove differential loading support #21467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 2, 2021
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
407 changes: 28 additions & 379 deletions packages/angular_devkit/build_angular/src/browser/index.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ describe('Browser Builder browser support', () => {
beforeEach(async () => {
await host.initialize().toPromise();
architect = (await createArchitect(host.root())).architect;

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

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -75,40 +75,6 @@ describe('Browser Builder scripts array', () => {
}
});

it('works in watch mode with differential loading', async () => {
const matches: Record<string, string> = {
'scripts.js': 'input-script',
'lazy-script.js': 'lazy-script',
'renamed-script.js': 'pre-rename-script',
'renamed-lazy-script.js': 'pre-rename-lazy-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-es2017.js" type="module"></script>' +
'<script src="main-es2017.js" type="module"></script>',
};

host.writeMultipleFiles(scripts);
host.appendToFile('src/main.ts', "\nimport './input-script.js';");

// Enable differential loading
host.appendToFile('.browserslistrc', '\nIE 11');

// Remove styles so we don't have to account for them in the index.html order check.
const { files } = await browserBuild(architect, host, target, {
styles: [],
scripts: getScriptsOption(),
watch: true,
} as {});

for (const [fileName, content] of Object.entries(matches)) {
expect(await files[fileName]).toMatch(content);
}
});

it('uglifies, uses sourcemaps, and adds hashes', async () => {
host.writeMultipleFiles(scripts);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ describe('Browser Builder styles', () => {
'.browserslistrc': 'IE 10',
});

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

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

expect(await files['main.js']).toContain('-ms-flex: 1;');
Expand All @@ -165,9 +162,6 @@ describe('Browser Builder styles', () => {
'.browserslistrc': 'IE 10',
});

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

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

expect(await files['main.js']).toContain('-ms-flex: 1;');
Expand Down Expand Up @@ -354,9 +348,6 @@ describe('Browser Builder styles', () => {
'.browserslistrc': 'IE 10',
});

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

const overrides = { extractCss: true, optimization: false };
const { files } = await browserBuild(architect, host, target, overrides);
expect(await files['styles.css']).toContain(tags.stripIndents`
Expand Down Expand Up @@ -394,9 +385,6 @@ describe('Browser Builder styles', () => {
'.browserslistrc': 'IE 10',
});

// Set target to ES5 to avoid differential loading and unnecessary testing time
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);
expect(await files['styles.css']).toContain('-ms-grid-columns:100px;');
Expand Down
16 changes: 4 additions & 12 deletions packages/angular_devkit/build_angular/src/dev-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ import { json, tags } from '@angular-devkit/core';
import * as path from 'path';
import { Observable, from } from 'rxjs';
import { concatMap, switchMap } from 'rxjs/operators';
import * as ts from 'typescript';
import * as url from 'url';
import webpack from 'webpack';
import webpackDevServer from 'webpack-dev-server';
import { Schema as BrowserBuilderSchema, OutputHashing } from '../browser/schema';
import { ExecutionTransformer } from '../transforms';
import { BuildBrowserFeatures, normalizeOptimization } from '../utils';
import { normalizeOptimization } from '../utils';
import { findCachePath } from '../utils/cache-path';
import { checkPort } from '../utils/check-port';
import { colors } from '../utils/color';
Expand Down Expand Up @@ -303,17 +302,10 @@ export function serveWebpackBrowser(
}

return from(setup()).pipe(
switchMap(({ browserOptions, webpackConfig, projectRoot, locale }) => {
switchMap(({ browserOptions, webpackConfig, locale }) => {
if (browserOptions.index) {
const { scripts = [], styles = [], baseHref, tsConfig } = browserOptions;
const { options: compilerOptions } = readTsconfig(tsConfig, workspaceRoot);
const target = compilerOptions.target || ts.ScriptTarget.ES5;
const buildBrowserFeatures = new BuildBrowserFeatures(projectRoot);

const { scripts = [], styles = [], baseHref } = browserOptions;
const entrypoints = generateEntryPoints({ scripts, styles });
const moduleEntrypoints = buildBrowserFeatures.isDifferentialLoadingNeeded(target)
? generateEntryPoints({ scripts: [], styles })
: [];

webpackConfig.plugins = [...(webpackConfig.plugins || [])];
webpackConfig.plugins.push(
Expand All @@ -322,7 +314,7 @@ export function serveWebpackBrowser(
outputPath: getIndexOutputFile(browserOptions.index),
baseHref,
entrypoints,
moduleEntrypoints,
moduleEntrypoints: [],
noModuleEntrypoints: ['polyfills-es5'],
deployUrl: browserOptions.deployUrl,
sri: browserOptions.subresourceIntegrity,
Expand Down
Loading