Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Questions about sourcemap #1457

Closed
imtaotao opened this issue May 12, 2022 · 5 comments · Fixed by #1626
Closed

Questions about sourcemap #1457

imtaotao opened this issue May 12, 2022 · 5 comments · Fixed by #1626

Comments

@imtaotao
Copy link

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) {
       ...
    }
}
@johnnyreilly
Copy link
Member

What processing did you have in mind?

@imtaotao
Copy link
Author

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.

@johnnyreilly
Copy link
Member

What problems does that cause?

@chipzhang
Copy link

chipzhang commented Mar 27, 2023

function loader(this: webpack.LoaderContext<LoaderOptions>, contents: string) {

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.

@Ka0o0
Copy link
Contributor

Ka0o0 commented Aug 28, 2023

@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: #1367 . I've tested the changes in one of our Vue projects and debugging works with those changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants