Skip to content

Commit

Permalink
refactor(@angular-devkit/build-angular): remove deprecated `evalSourc…
Browse files Browse the repository at this point in the history
…eMap`, `vendorSourceMap`, `profile` and `skipAppShell` options

BREAKING CHANGE:

The following deprecated devkit builders options have been removed:
- `skipAppShell:` This has no effect
- `evalSourceMap`: This done to improve performance in older versions of the CLI and is no longer needed
- `vendorSourceMap`: Use `sourceMap.vendor` instead
- `profile`: Use `NG_BUILD_PROFILING` environment variable instead
  • Loading branch information
alan-agius4 authored and mgechev committed Apr 27, 2020
1 parent 254994d commit 8fb7e58
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 181 deletions.
34 changes: 0 additions & 34 deletions packages/angular/cli/lib/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -765,16 +765,6 @@
}
]
},
"vendorSourceMap": {
"type": "boolean",
"description": "Resolve vendor packages sourcemaps.",
"default": false
},
"evalSourceMap": {
"type": "boolean",
"description": "Output in-file eval sourcemaps.",
"default": false
},
"vendorChunk": {
"type": "boolean",
"description": "Use a separate bundle containing only vendor libraries.",
Expand Down Expand Up @@ -892,11 +882,6 @@
"type": "string",
"description": "Path to ngsw-config.json."
},
"skipAppShell": {
"type": "boolean",
"description": "Flag to prevent building an app shell.",
"default": false
},
"index": {
"description": "Configures the generation of the application's HTML index.",
"oneOf": [
Expand Down Expand Up @@ -1290,15 +1275,6 @@
}
]
},
"vendorSourceMap": {
"type": "boolean",
"description": "When true, resolve vendor packages sourcemaps.",
"default": false
},
"evalSourceMap": {
"type": "boolean",
"description": "When true, output in-file eval sourcemaps."
},
"vendorChunk": {
"type": "boolean",
"description": "When true, use a separate bundle containing only vendor libraries."
Expand Down Expand Up @@ -1807,16 +1783,6 @@
}
]
},
"vendorSourceMap": {
"type": "boolean",
"description": "Resolve vendor packages sourcemaps.",
"default": false
},
"evalSourceMap": {
"type": "boolean",
"description": "Output in-file eval sourcemaps.",
"default": false
},
"vendorChunk": {
"type": "boolean",
"description": "Use a separate bundle containing only vendor libraries.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ export interface BuildOptions {
resourcesOutputPath?: string;
aot?: boolean;
sourceMap: SourceMapClass;
/** @deprecated since version 8. use sourceMap instead. */
vendorSourceMap?: boolean;
/** @deprecated since version 8 */
evalSourceMap?: boolean;
vendorChunk?: boolean;
commonChunk?: boolean;
baseHref?: string;
Expand Down Expand Up @@ -63,11 +59,8 @@ export interface BuildOptions {
subresourceIntegrity?: boolean;
serviceWorker?: boolean;
webWorkerTsConfig?: string;
/** @deprecated since version 8 **/
skipAppShell?: boolean;
statsJson: boolean;
forkTypeChecker: boolean;
profile?: boolean;

main: string;
polyfills?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,21 @@ export function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configurati
const {
crossOrigin = 'none',
subresourceIntegrity,
evalSourceMap,
extractLicenses,
vendorChunk,
commonChunk,
styles,
allowedCommonJsDependencies,
optimization,
} = buildOptions;

const extraPlugins = [];

let isEval = false;
const { styles: stylesOptimization, scripts: scriptsOptimization } = optimization;
const {
styles: stylesSourceMap,
scripts: scriptsSourceMap,
hidden: hiddenSourceMap,
} = buildOptions.sourceMap;

// See https://webpack.js.org/configuration/devtool/ for sourcemap types.
if ((stylesSourceMap || scriptsSourceMap) &&
evalSourceMap &&
!stylesOptimization &&
!scriptsOptimization) {
// Produce eval sourcemaps for development with serve, which are faster.
isEval = true;
}

if (subresourceIntegrity) {
extraPlugins.push(new SubresourceIntegrityPlugin({
hashFuncNames: ['sha384'],
Expand All @@ -59,7 +46,7 @@ export function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configurati
}));
}

if (!isEval && (scriptsSourceMap || stylesSourceMap)) {
if (scriptsSourceMap || stylesSourceMap) {
extraPlugins.push(getSourceMapDevTool(
scriptsSourceMap,
stylesSourceMap,
Expand All @@ -78,7 +65,7 @@ export function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configurati
}

return {
devtool: isEval ? 'eval' : false,
devtool: false,
resolve: {
mainFields: [
...(wco.supportES2015 ? ['es2015'] : []),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
allowMangle,
allowMinify,
cachingDisabled,
profilingEnabled,
shouldBeautify,
} from '../../../utils/environment-options';
import {
Expand Down Expand Up @@ -189,7 +190,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
}
}

if (buildOptions.profile || process.env['NG_BUILD_PROFILING']) {
if (profilingEnabled) {
extraPlugins.push(
new debug.ProfilingPlugin({
outputPath: path.resolve(root, `chrome-profiler-events${targetInFileName}.json`),
Expand Down
24 changes: 0 additions & 24 deletions packages/angular_devkit/build_angular/src/browser/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,6 @@
}
]
},
"vendorSourceMap": {
"type": "boolean",
"description": "Resolve vendor packages sourcemaps.",
"x-deprecated": true,
"default": false
},
"evalSourceMap": {
"type": "boolean",
"description": "Output in-file eval sourcemaps.",
"default": false,
"x-deprecated": true
},
"vendorChunk": {
"type": "boolean",
"description": "Use a separate bundle containing only vendor libraries.",
Expand Down Expand Up @@ -284,12 +272,6 @@
"type": "string",
"description": "Path to ngsw-config.json."
},
"skipAppShell": {
"type": "boolean",
"description": "Flag to prevent building an app shell.",
"default": false,
"x-deprecated": true
},
"index": {
"description": "Configures the generation of the application's HTML index.",
"oneOf": [
Expand Down Expand Up @@ -344,12 +326,6 @@
},
"default": []
},
"profile": {
"type": "boolean",
"description": "Output profile events for Chrome profiler.",
"default": false,
"x-deprecated": "Use \"NG_BUILD_PROFILING\" environment variable instead."
},
"rebaseRootRelativeCssUrls": {
"description": "Change root relative URLs in stylesheets to include base HREF and deploy URL. Use only for compatibility and transition. The behavior of this option is non-standard and will be removed in the next major release.",
"type": "boolean",
Expand Down
2 changes: 0 additions & 2 deletions packages/angular_devkit/build_angular/src/dev-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ const devServerBuildOverriddenKeys: (keyof DevServerBuilderOptions)[] = [
'optimization',
'aot',
'sourceMap',
'vendorSourceMap',
'evalSourceMap',
'vendorChunk',
'commonChunk',
'baseHref',
Expand Down
10 changes: 0 additions & 10 deletions packages/angular_devkit/build_angular/src/dev-server/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,6 @@
}
]
},
"vendorSourceMap": {
"type": "boolean",
"description": "Resolve vendor packages sourcemaps.",
"x-deprecated": true
},
"evalSourceMap": {
"type": "boolean",
"description": "Output in-file eval sourcemaps.",
"x-deprecated": true
},
"vendorChunk": {
"type": "boolean",
"description": "Use a separate bundle containing only vendor libraries."
Expand Down
11 changes: 0 additions & 11 deletions packages/angular_devkit/build_angular/src/karma/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,6 @@
}
]
},
"vendorSourceMap": {
"type": "boolean",
"description": "Resolve vendor packages sourcemaps.",
"x-deprecated": true,
"default": false
},
"evalSourceMap": {
"type": "boolean",
"description": "Output in-file eval sourcemaps.",
"x-deprecated": true
},
"progress": {
"type": "boolean",
"description": "Log progress to the console while building."
Expand Down
12 changes: 0 additions & 12 deletions packages/angular_devkit/build_angular/src/server/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,6 @@
}
]
},
"vendorSourceMap": {
"type": "boolean",
"description": "Resolve vendor packages sourcemaps.",
"x-deprecated": true,
"default": false
},
"evalSourceMap": {
"type": "boolean",
"description": "Output in-file eval sourcemaps.",
"default": false,
"x-deprecated": true
},
"vendorChunk": {
"type": "boolean",
"description": "Use a separate bundle containing only vendor libraries.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function isPresent(variable: string | undefined): variable is string {
return typeof variable === 'string' && variable !== '';
}

// Optimization and mangling
const debugOptimizeVariable = process.env['NG_BUILD_DEBUG_OPTIMIZE'];
const debugOptimize = (() => {
if (!isPresent(debugOptimizeVariable) || isDisabled(debugOptimizeVariable)) {
Expand Down Expand Up @@ -64,6 +65,7 @@ export const allowMangle = isPresent(mangleVariable)
export const shouldBeautify = debugOptimize.beautify;
export const allowMinify = debugOptimize.minify;

// Build cache
const cacheVariable = process.env['NG_BUILD_CACHE'];
export const cachingDisabled = isPresent(cacheVariable) && isDisabled(cacheVariable);
export const cachingBasePath = (() => {
Expand All @@ -76,3 +78,7 @@ export const cachingBasePath = (() => {

return cacheVariable;
})();

// Build profiling
const profilingVariable = process.env['NG_BUILD_PROFILING'];
export const profilingEnabled = isPresent(profilingVariable) && isEnabled(profilingVariable);
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ export function normalizeBrowserSchema(
options: BrowserBuilderSchema,
): NormalizedBrowserBuilderSchema {
const syncHost = new virtualFs.SyncDelegateHost(host);

const normalizedSourceMapOptions = normalizeSourceMaps(options.sourceMap || false);
normalizedSourceMapOptions.vendor = normalizedSourceMapOptions.vendor || options.vendorSourceMap;

return {
...options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
normalizeBrowserSchema,
} from '../utils';
import { BuildBrowserFeatures } from './build-browser-features';
import { profilingEnabled } from './environment-options';
import { I18nOptions, configureI18nBuild } from './i18n-options';

const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
Expand Down Expand Up @@ -113,7 +114,7 @@ export async function generateWebpackConfig(
webpackConfig.resolve.alias['zone.js/dist/zone'] = 'zone.js/dist/zone-evergreen';
}

if (options.profile || process.env['NG_BUILD_PROFILING']) {
if (profilingEnabled) {
const esVersionInFileName = getEsVersionForFileName(
tsConfig.options.target,
wco.buildOptions.esVersionInFileName,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,6 @@ describe('Browser Builder source map', () => {
expect(files['main.js.map']).toBeUndefined();
});

it('supports eval source map', async () => {
const { files } = await browserBuild(architect, host, target, {
sourceMap: true, evalSourceMap: true,
});

expect(files['main.js.map']).toBeUndefined();
expect(await files['main.js']).toContain('eval("function webpackEmptyAsyncContext');
});

it('supports hidden sourcemaps', async () => {
const overrides = {
sourceMap: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,6 @@ describe('Browser Builder external source map', () => {
expect(hasTsSourcePaths).toBe(true, `vendor.js.map should have '.ts' extentions`);
});

it(`works when using deprecated 'vendorSourceMap'`, async () => {
const overrides = {
sourceMap: {
scripts: true,
styles: true,
},
vendorSourceMap: true,
};

const { files } = await browserBuild(architect, host, target, overrides);
const sourcePaths: string[] = JSON.parse(await files['vendor.js.map']).sources;
const hasTsSourcePaths = sourcePaths.some(p => path.extname(p) == '.ts');
expect(hasTsSourcePaths).toBe(true, `vendor.js.map should have '.ts' extentions`);
});

it('does not map sourcemaps from external library when disabled', async () => {
const overrides = {
sourceMap: {
Expand Down

0 comments on commit 8fb7e58

Please sign in to comment.