-
Notifications
You must be signed in to change notification settings - Fork 12
Initial support for source map generation #23
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
Conversation
|
Hm... just found another PR which implements this... |
|
@visionmedia can we have a discussion of this? Do you still think that source map generation belongs to a separate module? |
|
Ok, I think I need to provide a rationale for this changeset. First of all, I'm aware of sheet CSS compiler which already supports source maps and uses the same format for input AST. Still sheet supports very limited source mapping — only selector position are mapped while current pull request also adds declaration mappings which allows you to Cmd/Ctrl + Click on property in Chrome Dev Tools and jump directly to source declaration (which is very handy if you use Chrome Dev Tools to edit source files). While I may invest my time to improve sheet's source mapping capabilities instead, I think that this functionality belongs to core and standard CSS compiler such as css-stringify. I saw you comment about css module being like Furthermore, this pull request doesn't adds much complexity — the only changes are usage of a base compiler class with two auxiliary methods and using Also there are no (or little) reasons to maintain two CSS compilers (sheet and css-stringify) which differ only in support of source mapping. |
|
I've implemented andreypopp/xcss bundler on top of css-stringify with this patch applied — everything works well and rework transforms in the wild (rework-vars, rework-inherit, rework-macro, autoprefixer) don't break mappings. |
|
⭐ |
|
🍻 |
|
looks pretty good. Some transformations will definitely break mappings to some degree, but maybe not enough to worry about, at least the files etc will be right. im not super convinced that it needs to live in this library since higher-level things like styl or autoprefixer could use whatever stringifier they want, and it complicates the client-side usage via component with the extra deps, but we could probably have it just ignore source map support on the client without those deps |
|
@visionmedia ping me if you want it to be squashed into a single commit and/or add specs. I'm not familiar with component so I don't know how to make the thing so it ignores |
|
the only thing we'd have to change to have it ignore is conditionally augment the compress/identity compiler prototypes so that we don't have to |
|
something like |
|
@visionmedia but we still have to call Or you mean that component's builder doesn't analyse dependencies by parsing AST and so moving |
|
Just did that. |
|
yup that's correct it just uses the deps listed in component.json so as long as you don't actually invoke it there's no problem, with the current implementation at least, that may change in the future. ill pull this down in a bit and squash |
|
tests would be good too :D |
|
+1 for tests. |
|
pushed add/sourcemaps up with a few small changes |
|
Branch |
This is related to reworkcss/rework#109.
Ok, this is just an initial support. I think it's time to try to get the API right, currently it adds
sourceMapoption which changes the returned value to{code: "...", map: {...}}.