Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

browserify and files that allready have a sourcemap

I have some JavaScript code that is compiled to commonJS modules from arbitrary compile-to-JS languages and I would like to debug the browserified code using sourcemaps.

So my files have a //# sourceMappingURL=index.js.map already and I'd expect browserify to read that and transform them so I can debug with my original non-JS language.

Do I need another transform for this?

I tried it with browserify's debug flag, and then it does generate a sourcemap but it is for the intermediate JS files, and NOT the original non-JS files. I even see the original //# sourceMappingURL statements lingering in the bundle, and my browsers debugger doesn't like it a all.

Is this possible at all?

I see this: Keep original typescript source maps after using browserify But it doesn't work.

like image 843
Bartvds Avatar asked Jun 06 '14 16:06

Bartvds


1 Answers

You can run Sorcery on the output of broswerify. Sorcery will resolve a chain of sourcemaps until it gets to the original files. Sorcery emits a new sourcemap that has the original sources. This is not tied to any specific tool so it will work with webpack.

Installation: npm install -g sorcery

Usage: sorcery -i outputOfBrowserify.js That command will overwrite the file and its source map in place.

like image 182
michaelmesser Avatar answered Oct 11 '22 18:10

michaelmesser