ts-loader
ts-loader copied to clipboard
Questions about sourcemap
Why is the upstream sourcemap not processed in the loader?
https://github.com/TypeStrong/ts-loader/blob/main/src/index.ts#L34
function loader(this: webpack.LoaderContext<LoaderOptions>, contents: string, map?: Sourcemap) {
if (map) {
...
}
}
What processing did you have in mind?
I have a loader that processes source files, and then passes the source code
and sourcemap
to ts-loader
, but ts-loader
doesn't seem to merge the sourcemap passed from upstream loader.
What problems does that cause?
https://github.com/TypeStrong/ts-loader/blob/9533b2dc992392623e04645b1972332bddef0c76/src/index.ts#L34
Currently, ts-loader
force discards any source maps generated by previous loaders.
In its exported loader entry function, it just silently ignores the third parameter, which is the source map returned by previous loaders.
If I have some pre-processor loaders running before ts-loader
, it silently discards the source maps.
This is very bad.
You should at lease print a warning info, if the third parameter is not null.
@johnnyreilly for us specifically this causes that we are not able to debug Vue SFC TypeScript files. This is because the ts-loader is the second loader after the vue-loader and should respect the input source maps generated by the vue-loader.
I've seen that there has already been made a suggestion on how to handle this: https://github.com/TypeStrong/ts-loader/pull/1367 . I've tested the changes in one of our Vue projects and debugging works with those changes.