Skip to content

Source map fixes #74

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

Merged
merged 4 commits into from
Mar 8, 2014
Merged

Source map fixes #74

merged 4 commits into from
Mar 8, 2014

Conversation

conradz
Copy link
Contributor

@conradz conradz commented Mar 6, 2014

(In reference to the changes mentioned in reworkcss/rework#144)

This reverts 190ba98 and removes some of the references to filename that were also added.

This reverts commit 190ba98.

Conflicts:
	History.md
	Readme.md
	test/css-parse.js
@conradz
Copy link
Contributor Author

conradz commented Mar 6, 2014

Do we still want another property on each node that includes the CSS code that generated the node (basically what source was in 190ba98)? This PR totally removes that functionality.

@jonathanong
Copy link
Contributor

i'm not sure what sourcemap does. something like .string would be nice. should be non-enumerable though. i still think it's necessary because if you have CSS from multiple sources, i.e. when you use an @import plugin, you want to know the exact source string and location when you throw an error

@conradz
Copy link
Contributor Author

conradz commented Mar 7, 2014

mozilla/source-map has setSourceContent, which would do basically what this is, although if I understand it correctly it sets the source of a file that is included in the map (the source is not associated with a certain node, but with a certain file name that is referenced by a node).

To be the closest to the source-map module, we would include a map (attached to the .stylesheet object) of each file that is included in the stylesheet and its contents. Then css-stringify could consume this map and include each files contents in the source map (this is very similar to how browserify's source maps behave).

If we use the previous method (of attaching to node.position), I would suggest using content or sourceContent.

@jonathanong
Copy link
Contributor

yeah either content or sourceContent would work. we need it since if you import a section of one stylesheet to another, you won't have a reference to the content (unless done correctly, but let's not assume it's done correctly). also, when an error occurs, a reporter should be able to print out the content of the error just by referencing properties on .node, which is why i want all the properties on the node.

but i'm not sure how that relates to source-map heh

@conradz
Copy link
Contributor Author

conradz commented Mar 7, 2014

I added the node.position.content property, basically the same way node.position.source had been.

Note that .content is actually not non-enumerable, even though it is a prototype property. A simple for (var k in node) will still iterate over it. A prototype property still accomplishes the purpose of keeping it out of JSON.stringify output, though.

With these fixes, css-stringify should be able to take the parsed output and embed all the source file contents in the source map themselves, instead of simply linking to the filename.

@conradz
Copy link
Contributor Author

conradz commented Mar 7, 2014

@jonathanong is this ready to merge? With this change position.content now contains what position.source did before this PR. position.source contains exactly the same thing as it did in previous versions.

@jonathanong
Copy link
Contributor

yeah looks good to me.

conradz added a commit that referenced this pull request Mar 8, 2014
@conradz conradz merged commit 9268ce8 into master Mar 8, 2014
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 this pull request may close these issues.

2 participants