You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I've been experimenting with this repository. I tried to generate a simple project to use source maps using Webpack: https://github.com/eloparco/test-source-maps, where I produce a js bundle starting from Typescript and I want to use source maps for the mapping between the two.
I tried to play around with the generated source maps:
constSourceMapConsumer=require("source-map").SourceMapConsumer;constfs=require("fs");constSOURCEMAP_ABSOUTE_PATH="/path/to/test-source-maps/dist/bundle.js.map";constORIGINAL_ABSOLUTE_PATH="/path/to/test-source-maps/src/index.ts";constGENERATED_ABSOLUTE_PATH="/path/to/test-source-maps/dist/bundle.js";constORIGINAL_LINE=11;letjson=JSON.parse(fs.readFileSync(SOURCEMAP_ABSOUTE_PATH).toString());SourceMapConsumer.with(json,null,(consumer)=>{console.log(consumer.sources);constgenerated=consumer.generatedPositionFor({source: ORIGINAL_ABSOLUTE_PATH,line: ORIGINAL_LINE,column: 0,});console.log(generated);constoriginal=consumer.originalPositionFor({line: generated.line,column: generated.column,});console.log(original);assert(original.line===ORIGINAL_LINE);// <------------ This assertion fails!!!});
Here I use generatedPositionFor() to get the mapping from the original .ts file to the corresponding .js file. Then, I try to do the opposite and feed the line and column previously retrieved to originalPositionFor(), expecting it to return the original line/column that I passed to generatedPositionFor(). But that doesn't happen.
Is my understanding of source maps wrong? Or am I doing something wrong in the Webpack configuration?
Thanks
The text was updated successfully, but these errors were encountered:
I found out that the problem has something to do with webpack.
If I add "sourceMap": true, to tsconfig.json and run tsc instead of webpack, I get what I was expecting.
Even when using tsc (with webpack instead it was minifying the generated source and it was causing issues), the mapping is not always correct. Is there a recommended way (or even better, an example project) to generate the source file and source map in a format that is compatible with this library?
Hello,
I've been experimenting with this repository. I tried to generate a simple project to use source maps using Webpack: https://github.com/eloparco/test-source-maps, where I produce a js bundle starting from Typescript and I want to use source maps for the mapping between the two.
I tried to play around with the generated source maps:
Here I use
generatedPositionFor()
to get the mapping from the original.ts
file to the corresponding.js
file. Then, I try to do the opposite and feed the line and column previously retrieved tooriginalPositionFor()
, expecting it to return the original line/column that I passed togeneratedPositionFor()
. But that doesn't happen.Is my understanding of source maps wrong? Or am I doing something wrong in the Webpack configuration?
Thanks
The text was updated successfully, but these errors were encountered: