This commit is contained in:
Johannes
2022-12-02 13:03:16 +01:00
parent 9433821f09
commit f73bb21f27
7 changed files with 203 additions and 29 deletions

View File

@@ -18,6 +18,7 @@ import ts = require('typescript');
import * as File from 'vinyl';
import * as task from './task';
import { Mangler } from './mangleTypeScript';
import { RawSourceMap } from 'source-map';
const watch = require('./watch');
@@ -125,10 +126,11 @@ export function compileTask(src: string, out: string, build: boolean): () => Nod
if (build) {
let ts2tsMangler = new Mangler(compile.projectPath);
const newContentsByFileName = ts2tsMangler.computeNewFileContents();
mangleStream = es.through(function write(data: File) {
mangleStream = es.through(function write(data: File & { sourceMap?: RawSourceMap }) {
const newContents = newContentsByFileName.get(data.path);
if (newContents !== undefined) {
data.contents = Buffer.from(newContents);
data.contents = Buffer.from(newContents.out);
data.sourceMap = newContents.sourceMap && JSON.parse(newContents.sourceMap);
}
this.push(data);
}, function end() {