build: fix sourcemap paths (#9068)

This commit is contained in:
Paul Gschwendtner
2017-12-21 00:13:25 +01:00
committed by Joey Perrott
parent bf03d14c98
commit d773102a1f
2 changed files with 15 additions and 7 deletions
+9 -4
View File
@@ -4,6 +4,7 @@ import {buildConfig} from './build-config';
import {BuildPackage} from './build-package';
import {rollupRemoveLicensesPlugin} from './rollup-remove-licenses';
import {rollupGlobals, dashCaseToCamelCase} from './rollup-globals';
import {remapSourcemap} from './sourcemap-remap';
// There are no type definitions available for these imports.
const rollup = require('rollup');
@@ -66,7 +67,6 @@ export class PackageBundler {
*/
private async bundleEntryPoint(config: BundlesConfig) {
// Build FESM-2015 bundle file.
// TODO: re-add sorcery when we upgrade to Angular 5.x
await this.createRollupBundle({
moduleName: config.moduleName,
entry: config.entryFile,
@@ -75,7 +75,6 @@ export class PackageBundler {
});
// Build FESM-5 bundle file.
// TODO: re-add sorcery when we upgrade to Angular 5.x
await this.createRollupBundle({
moduleName: config.moduleName,
entry: config.esm5EntryFile,
@@ -84,7 +83,6 @@ export class PackageBundler {
});
// Create UMD bundle of ES5 output.
// TODO: re-add sorcery when we upgrade to Angular 5.x
await this.createRollupBundle({
moduleName: config.moduleName,
entry: config.esm5Dest,
@@ -93,8 +91,15 @@ export class PackageBundler {
});
// Create a minified UMD bundle using UglifyJS
// TODO: re-add sorcery when we upgrade to Angular 5.x
uglifyJsFile(config.umdDest, config.umdMinDest);
// Remaps the sourcemaps to be based on top of the original TypeScript source files.
await Promise.all([
remapSourcemap(config.esm2015Dest),
remapSourcemap(config.esm5Dest),
remapSourcemap(config.umdDest),
remapSourcemap(config.umdMinDest),
]);
}
/** Creates a rollup bundle of a specified JavaScript file.*/
+6 -3
View File
@@ -1,18 +1,21 @@
import {writeFileSync} from 'fs';
import {basename} from 'path';
// There are no type definitions available for these imports.
const uglify = require('uglify-js');
/** Minifies a JavaScript file by using UglifyJS2. Also writes sourcemaps to the output. */
export function uglifyJsFile(inputPath: string, outputPath: string) {
const sourcemapOut = `${outputPath}.map`;
const sourceMapPath = `${outputPath}.map`;
const result = uglify.minify(inputPath, {
outSourceMap: sourcemapOut,
inSourceMap: `${inputPath}.map`,
outSourceMap: basename(sourceMapPath),
output: {
comments: 'some'
}
});
writeFileSync(outputPath, result.code);
writeFileSync(sourcemapOut, result.map);
writeFileSync(sourceMapPath, result.map);
}