Bartvds
Bartvds

Reputation: 3500

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.

Upvotes: 9

Views: 641

Answers (1)

michaelmesser
michaelmesser

Reputation: 3726

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.

Upvotes: 3

Related Questions