-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Source-map support for multiple input source files #3323
Conversation
Current coverage is
|
Why not concat the files after the transform as opposed to before transform? And then combine the sourcemaps. I know that using the combine-source-map module is awfully slow but you can use this neat trick: It didn't have full browser support last I checked, but let me know if that solves it for you |
Hey @amasad, thanks for the link. That's an interesting work-around. I'm not sure it will work for me - I'm building a bundler similar in function to webpack, and losing broad browser support would be a significant drawback. The change proposed here is really the only thing keeping Babel from being used in place of something like There's definitely risk in opening Babel to new use-cases like this. And I also recognize that there may not be a lot in it for the Babel maintainers :) But if there's anything I can do to make it a more attractive change, I'm definitely open. Since it is a minimal and non-breaking change, I hope that there's a possibility. |
@@ -6,11 +6,12 @@ import { SourceLocation } from "../util/location"; | |||
const pp = Parser.prototype; | |||
|
|||
class Node { | |||
constructor(pos?: number, loc?: SourceLocation) { | |||
constructor(pos?: number, loc?: SourceLocation, filename?: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filename?: string
OK. Sounds good. Can you please add tests? |
…ti-source object.
Source-map support for multiple input source files
Source-map support for multiple input source files
This PR allows tools built on top of Babel to parse multiple JS sources to AST, optionally transform them, and combine them. When output code is generated, source-maps will point to the original source files.
The minimum change necessary for my use case is contained in the first commit. However, the additional changes add support for this use case to both ends of the Babel toolchain (and removes unnecessary traversals of the AST outside of Babel).
Documentation was added where it seemed it would be helpful. I did not add tests since the test helpers assume a 1:1 transformation. If you'd like me to add tests, let me know what it should look like.
Thanks!