Skip to content

Commit d773102

Browse files
devversionjosephperrott
authored andcommitted
build: fix sourcemap paths (#9068)
1 parent bf03d14 commit d773102

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

tools/package-tools/build-bundles.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {buildConfig} from './build-config';
44
import {BuildPackage} from './build-package';
55
import {rollupRemoveLicensesPlugin} from './rollup-remove-licenses';
66
import {rollupGlobals, dashCaseToCamelCase} from './rollup-globals';
7+
import {remapSourcemap} from './sourcemap-remap';
78

89
// There are no type definitions available for these imports.
910
const rollup = require('rollup');
@@ -66,7 +67,6 @@ export class PackageBundler {
6667
*/
6768
private async bundleEntryPoint(config: BundlesConfig) {
6869
// Build FESM-2015 bundle file.
69-
// TODO: re-add sorcery when we upgrade to Angular 5.x
7070
await this.createRollupBundle({
7171
moduleName: config.moduleName,
7272
entry: config.entryFile,
@@ -75,7 +75,6 @@ export class PackageBundler {
7575
});
7676

7777
// Build FESM-5 bundle file.
78-
// TODO: re-add sorcery when we upgrade to Angular 5.x
7978
await this.createRollupBundle({
8079
moduleName: config.moduleName,
8180
entry: config.esm5EntryFile,
@@ -84,7 +83,6 @@ export class PackageBundler {
8483
});
8584

8685
// Create UMD bundle of ES5 output.
87-
// TODO: re-add sorcery when we upgrade to Angular 5.x
8886
await this.createRollupBundle({
8987
moduleName: config.moduleName,
9088
entry: config.esm5Dest,
@@ -93,8 +91,15 @@ export class PackageBundler {
9391
});
9492

9593
// Create a minified UMD bundle using UglifyJS
96-
// TODO: re-add sorcery when we upgrade to Angular 5.x
9794
uglifyJsFile(config.umdDest, config.umdMinDest);
95+
96+
// Remaps the sourcemaps to be based on top of the original TypeScript source files.
97+
await Promise.all([
98+
remapSourcemap(config.esm2015Dest),
99+
remapSourcemap(config.esm5Dest),
100+
remapSourcemap(config.umdDest),
101+
remapSourcemap(config.umdMinDest),
102+
]);
98103
}
99104

100105
/** Creates a rollup bundle of a specified JavaScript file.*/

tools/package-tools/minify-sources.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import {writeFileSync} from 'fs';
2+
import {basename} from 'path';
23

34
// There are no type definitions available for these imports.
45
const uglify = require('uglify-js');
56

67
/** Minifies a JavaScript file by using UglifyJS2. Also writes sourcemaps to the output. */
78
export function uglifyJsFile(inputPath: string, outputPath: string) {
8-
const sourcemapOut = `${outputPath}.map`;
9+
const sourceMapPath = `${outputPath}.map`;
10+
911
const result = uglify.minify(inputPath, {
10-
outSourceMap: sourcemapOut,
12+
inSourceMap: `${inputPath}.map`,
13+
outSourceMap: basename(sourceMapPath),
1114
output: {
1215
comments: 'some'
1316
}
1417
});
1518

1619
writeFileSync(outputPath, result.code);
17-
writeFileSync(sourcemapOut, result.map);
20+
writeFileSync(sourceMapPath, result.map);
1821
}

0 commit comments

Comments
 (0)