Skip to content

Commit

Permalink
Revert "fix(@angular-devkit/build-angular): don't generate `vendor.js…
Browse files Browse the repository at this point in the history
….map` when vendor sourcemaps is disabled"

This reverts commit b17763b.

Closes #19236
  • Loading branch information
alan-agius4 authored and filipesilva committed Nov 3, 2020
1 parent 295bc83 commit 79ec417
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ describe('Browser Builder with differential loading', () => {
'runtime-es5.js.map',

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

'styles.css',
'styles.css.map',
Expand Down Expand Up @@ -88,7 +90,9 @@ describe('Browser Builder with differential loading', () => {
'runtime-es5.js.map',

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

'styles.css',
'styles.css.map',
Expand Down Expand Up @@ -126,7 +130,9 @@ describe('Browser Builder with differential loading', () => {
'runtime-es5.js.map',

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

'styles.css',
'styles.css.map',
Expand All @@ -152,6 +158,7 @@ describe('Browser Builder with differential loading', () => {
'runtime.js.map',

'vendor.js',
'vendor.js.map',

'styles.css',
'styles.css.map',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('Browser Builder external source map', () => {
expect(hasTsSourcePaths).toBe(true, `vendor.js.map should have '.ts' extentions`);
});

it(`does not generate 'vendor.js.map' when vendor sourcemap is disabled`, async () => {
it('does not map sourcemaps from external library when disabled', async () => {
const overrides = {
sourceMap: {
scripts: true,
Expand All @@ -44,6 +44,8 @@ describe('Browser Builder external source map', () => {
};

const { files } = await browserBuild(architect, host, target, overrides);
expect(files['vendor.js.map']).toBeUndefined();
const sourcePaths: string[] = JSON.parse(await files['vendor.js.map']).sources;
const hasTsSourcePaths = sourcePaths.some(p => path.extname(p) == '.ts');
expect(hasTsSourcePaths).toBe(false, `vendor.js.map not should have '.ts' extentions`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configurati
styles: stylesSourceMap,
scripts: scriptsSourceMap,
hidden: hiddenSourceMap,
vendor: vendorSourceMap,
} = buildOptions.sourceMap;

if (subresourceIntegrity) {
Expand Down Expand Up @@ -56,7 +55,6 @@ export function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configurati
stylesSourceMap,
buildOptions.differentialLoadingMode ? true : hiddenSourceMap,
false,
vendorSourceMap,
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export function getServerConfig(wco: WebpackConfigOptions): Configuration {
} = wco.buildOptions;

const extraPlugins = [];
const { scripts, styles, hidden, vendor } = sourceMap;
const { scripts, styles, hidden } = sourceMap;
if (scripts || styles) {
extraPlugins.push(getSourceMapDevTool(scripts, styles, hidden, false, vendor));
extraPlugins.push(getSourceMapDevTool(scripts, styles, hidden));
}

const externals: Configuration['externals'] = [...externalDependencies];
Expand Down
19 changes: 7 additions & 12 deletions packages/angular_devkit/build_angular/src/webpack/configs/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,13 @@ export function getTestConfig(
});
}

if (sourceMap) {
const { styles, scripts, vendor } = sourceMap;

if (styles || scripts) {
extraPlugins.push(getSourceMapDevTool(
scripts,
styles,
false,
true,
vendor,
));
}
if (sourceMap.scripts || sourceMap.styles) {
extraPlugins.push(getSourceMapDevTool(
sourceMap.scripts,
sourceMap.styles,
false,
true,
));
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export function getSourceMapDevTool(
stylesSourceMap: boolean | undefined,
hiddenSourceMap = false,
inlineSourceMap = false,
vendorSourceMap = false,
): SourceMapDevToolPlugin {
const include = [];
if (scriptsSourceMap) {
Expand All @@ -94,7 +93,6 @@ export function getSourceMapDevTool(
sourceRoot: 'webpack:///',
moduleFilenameTemplate: '[resource-path]',
append: hiddenSourceMap ? false : undefined,
exclude: vendorSourceMap ? undefined : /vendor.*\.js/,
});
}

Expand Down
6 changes: 3 additions & 3 deletions tests/legacy-cli/e2e/tests/build/sourcemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export default async function () {
await ng('build', '--output-hashing=bundles', '--source-map');

await ng('build', '--prod', '--output-hashing=none', '--source-map');
await testForSourceMaps(5);
await testForSourceMaps(6);

await ng('build', '--output-hashing=none', '--source-map');
await testForSourceMaps(6);
await testForSourceMaps(8);
}

async function testForSourceMaps(expectedNumberOfFiles: number): Promise <void> {
Expand All @@ -29,7 +29,7 @@ async function testForSourceMaps(expectedNumberOfFiles: number): Promise <void>

let count = 0;
for (const file of files) {
if (!file.endsWith('.js') || file.startsWith('vendor-')) {
if (!file.endsWith('.js')) {
continue;
}

Expand Down

0 comments on commit 79ec417

Please sign in to comment.