Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
301 views
in Technique[技术] by (71.8m points)

javascript - Keep original typescript source maps after using browserify

Background: I am compiling 2 dependent TypeScript files to js, which produces also source maps (one source map per file) using tsc 1.0

I'm using -m commonjs and then use browserify to generate a single bundle.js

However I noticed that I get the original source map references twice in the bundle, which doesn't seem to work.

Passing --debug doesn't seem to do the trick either.

I had a feeling this issue: https://github.com/substack/node-browserify/issues/325 is somewhat related, but I couldn't figure out how the issue was resolved.

Also https://github.com/substack/browser-pack was suggested, but again I don't fully understand how to use it, is it a replacement to browserify?

Bottom line, I would like to merge the 2 js files but "merge" the js to ts source maps using browserify. Is that possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

tsify is a browserify plugin that is better and replaces e.g. typescriptifier.

npm install tsify browserify watchify

You use tsify like this:

browserify src/index.ts -p tsify --debug -o build/index.js

Notice that this supports browserify --debug switch, no extra tricks required. So you can also use it with watchify like this:

watchify src/index.ts -p tsify --debug -o build/index.js


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...