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

Nested source maps #211

Closed
matthiasg opened this issue Jul 1, 2020 · 3 comments
Closed

Nested source maps #211

matthiasg opened this issue Jul 1, 2020 · 3 comments

Comments

@matthiasg
Copy link

When including a submodule which in turn exposes compiled javascript code (eg from typescript) the files exposed and included often have associated sourcemaps next to them. In that case it would be extremely helpful to include that mapping into the resulting output.

If nested sourcemaps are not supported is there a way to directly have the lookup resolve to the original src file instead of the compiled output ? Right now, the module resolution algorithm (which one are you using ?) is resolving via the package.json main,module,or export property which cannot include the ts file of course.

@evanw
Copy link
Owner

evanw commented Jul 1, 2020

If nested sourcemaps are not supported

That's correct, they are currently not supported. This is not a simple change because the current source map infrastructure assumes that all source mappings from a given input file come from that file. I agree it would be a useful feature to be able to do this.

is there a way to directly have the lookup resolve to the original src file instead of the compiled output ?

No, although changing what a path resolves to is a use case I have in mind for plugins. Plugins aren't supported yet but I will look into adding plugins in the future.

Right now, the module resolution algorithm (which one are you using ?)

I'm attempting to use the same algorithm that other bundlers use, which is a combination of the node resolution algorithm, certain bundler-specific features such as the browser field in package.json, and the TypeScript paths feature from tsconfig.json.

@matthiasg
Copy link
Author

matthiasg commented Jul 2, 2020

Using the tsconfig might actually be a long-term way, provided there is some kind of filtering method to allow exemptions of individual modules.

Alternatively a neighbouring sourcemap file could be inspected and if it only points at one input file and that is a supported file type, the exact path is already present, so instead of using the .js file the source file can be used.

The tsconfig is pretty straightforward of course as it more or less directly maps input folders to an output folder, thus finding the appropriate sub-path replacement operation is possible.

The exception is, when typescript is used for bundling, which could be left out until nested source maps are supported.

@matthiasg
Copy link
Author

Hoooray !!! Will definitely run a new test with this feature as soon as I can

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

No branches or pull requests

2 participants