Skip to content

Commit 79ec417

Browse files
alan-agius4filipesilva
authored andcommitted
Revert "fix(@angular-devkit/build-angular): don't generate vendor.js.map when vendor sourcemaps is disabled"
This reverts commit b17763b. Closes #19236
1 parent 295bc83 commit 79ec417

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

packages/angular_devkit/build_angular/src/browser/specs/differential_loading_spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ describe('Browser Builder with differential loading', () => {
5050
'runtime-es5.js.map',
5151

5252
'vendor-es2015.js',
53+
'vendor-es2015.js.map',
5354
'vendor-es5.js',
55+
'vendor-es5.js.map',
5456

5557
'styles.css',
5658
'styles.css.map',
@@ -88,7 +90,9 @@ describe('Browser Builder with differential loading', () => {
8890
'runtime-es5.js.map',
8991

9092
'vendor-es2016.js',
93+
'vendor-es2016.js.map',
9194
'vendor-es5.js',
95+
'vendor-es5.js.map',
9296

9397
'styles.css',
9498
'styles.css.map',
@@ -126,7 +130,9 @@ describe('Browser Builder with differential loading', () => {
126130
'runtime-es5.js.map',
127131

128132
'vendor-esnext.js',
133+
'vendor-esnext.js.map',
129134
'vendor-es5.js',
135+
'vendor-es5.js.map',
130136

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

154160
'vendor.js',
161+
'vendor.js.map',
155162

156163
'styles.css',
157164
'styles.css.map',

packages/angular_devkit/build_angular/src/browser/specs/vendor-source-map_spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('Browser Builder external source map', () => {
3434
expect(hasTsSourcePaths).toBe(true, `vendor.js.map should have '.ts' extentions`);
3535
});
3636

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

4646
const { files } = await browserBuild(architect, host, target, overrides);
47-
expect(files['vendor.js.map']).toBeUndefined();
47+
const sourcePaths: string[] = JSON.parse(await files['vendor.js.map']).sources;
48+
const hasTsSourcePaths = sourcePaths.some(p => path.extname(p) == '.ts');
49+
expect(hasTsSourcePaths).toBe(false, `vendor.js.map not should have '.ts' extentions`);
4850
});
4951
});

packages/angular_devkit/build_angular/src/webpack/configs/browser.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configurati
2828
styles: stylesSourceMap,
2929
scripts: scriptsSourceMap,
3030
hidden: hiddenSourceMap,
31-
vendor: vendorSourceMap,
3231
} = buildOptions.sourceMap;
3332

3433
if (subresourceIntegrity) {
@@ -56,7 +55,6 @@ export function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configurati
5655
stylesSourceMap,
5756
buildOptions.differentialLoadingMode ? true : hiddenSourceMap,
5857
false,
59-
vendorSourceMap,
6058
));
6159
}
6260

packages/angular_devkit/build_angular/src/webpack/configs/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export function getServerConfig(wco: WebpackConfigOptions): Configuration {
2828
} = wco.buildOptions;
2929

3030
const extraPlugins = [];
31-
const { scripts, styles, hidden, vendor } = sourceMap;
31+
const { scripts, styles, hidden } = sourceMap;
3232
if (scripts || styles) {
33-
extraPlugins.push(getSourceMapDevTool(scripts, styles, hidden, false, vendor));
33+
extraPlugins.push(getSourceMapDevTool(scripts, styles, hidden));
3434
}
3535

3636
const externals: Configuration['externals'] = [...externalDependencies];

packages/angular_devkit/build_angular/src/webpack/configs/test.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,13 @@ export function getTestConfig(
4848
});
4949
}
5050

51-
if (sourceMap) {
52-
const { styles, scripts, vendor } = sourceMap;
53-
54-
if (styles || scripts) {
55-
extraPlugins.push(getSourceMapDevTool(
56-
scripts,
57-
styles,
58-
false,
59-
true,
60-
vendor,
61-
));
62-
}
51+
if (sourceMap.scripts || sourceMap.styles) {
52+
extraPlugins.push(getSourceMapDevTool(
53+
sourceMap.scripts,
54+
sourceMap.styles,
55+
false,
56+
true,
57+
));
6358
}
6459

6560
return {

packages/angular_devkit/build_angular/src/webpack/utils/helpers.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export function getSourceMapDevTool(
7373
stylesSourceMap: boolean | undefined,
7474
hiddenSourceMap = false,
7575
inlineSourceMap = false,
76-
vendorSourceMap = false,
7776
): SourceMapDevToolPlugin {
7877
const include = [];
7978
if (scriptsSourceMap) {
@@ -94,7 +93,6 @@ export function getSourceMapDevTool(
9493
sourceRoot: 'webpack:///',
9594
moduleFilenameTemplate: '[resource-path]',
9695
append: hiddenSourceMap ? false : undefined,
97-
exclude: vendorSourceMap ? undefined : /vendor.*\.js/,
9896
});
9997
}
10098

tests/legacy-cli/e2e/tests/build/sourcemap.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export default async function () {
1515
await ng('build', '--output-hashing=bundles', '--source-map');
1616

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

2020
await ng('build', '--output-hashing=none', '--source-map');
21-
await testForSourceMaps(6);
21+
await testForSourceMaps(8);
2222
}
2323

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

3030
let count = 0;
3131
for (const file of files) {
32-
if (!file.endsWith('.js') || file.startsWith('vendor-')) {
32+
if (!file.endsWith('.js')) {
3333
continue;
3434
}
3535

0 commit comments

Comments
 (0)