less.js icon indicating copy to clipboard operation
less.js copied to clipboard

Allow creating a source map

Open lukeapage opened this issue 14 years ago • 125 comments

see https://github.com/nex3/sass/pull/569

and #1038

We should output source maps in the new format

lukeapage avatar Nov 28 '12 05:11 lukeapage

+1

uzikilon avatar Jan 17 '13 05:01 uzikilon

:+1:

gabeins avatar Jan 17 '13 11:01 gabeins

+1

mrdevinmob avatar Jan 17 '13 16:01 mrdevinmob

+2

matthew-dean avatar Jan 18 '13 20:01 matthew-dean

+1

madcampos avatar Feb 16 '13 09:02 madcampos

+1, obviously!

Soviut avatar Feb 16 '13 09:02 Soviut

+1

EarMaster avatar Feb 27 '13 12:02 EarMaster

+1

aredridel avatar Feb 27 '13 12:02 aredridel

if anyone wants to work on this

https://github.com/cloudhead/less.js/tree/import-interpolation

now has a visitor pattern implemented.

you should be able to use this to go over the nodes and grab original input information.

What you don't know is the target (css) line number.

To do that I would suggest having functions on the toCSS env object which build up the css and keep track of the current line number. You can then store that line number against the node.

After that it should be simple.

lukeapage avatar Feb 27 '13 13:02 lukeapage

i'm not good at compiler theory (in fact i am at this course at college now) and haven't looked up less' code, but can't just write to a variable say, lineNumber and at each line break increment it? it should keep the line number state, after that it could be exposed to the function mapping the lines.

madcampos avatar Feb 27 '13 14:02 madcampos

@madcampos

yes.. that is this bit of the implementation I described.

having functions on the toCSS env object which build up the css and keep track of the current line number.

you need to keep track of the line number on the env object but also store its current value against each node as you output the css, then the ast has the source and the target line numbers and a mapping can be made.

lukeapage avatar Feb 27 '13 14:02 lukeapage

+1

jyonker avatar May 22 '13 17:05 jyonker

lol, we're all for it, looks like we just need an adept JavaScript / LESS programmer to fix it up and do a pull request. ;-)

matthew-dean avatar Jun 04 '13 16:06 matthew-dean

+1 very important feature

ivan4th avatar Jun 07 '13 21:06 ivan4th

You may want to use the SourceMapGenerator here: https://github.com/mozilla/source-map

ChrisCinelli avatar Jun 10 '13 09:06 ChrisCinelli

I wrote a simple less middleware https://gist.github.com/undoZen/5806774

undoZen avatar Jun 18 '13 16:06 undoZen

That looks awesome!


Aria Stewart

On June 18, 2013 at 12:13:41 PM, 安动生 ([email protected]) wrote: I wrote a simple less middleware
https://gist.github.com/undoZen/5806774 —
Reply to this email directly or view it on GitHub.

aredridel avatar Jun 18 '13 16:06 aredridel

Thanks for the middleware, i will try this at home. Any way it gets to be merged into less core? Or some solution like this? Em 18/06/2013 12:25, "Aria Stewart" [email protected] escreveu:

That looks awesome!


Aria Stewart

On June 18, 2013 at 12:13:41 PM, 安动生 ([email protected]) wrote: I wrote a simple less middleware https://gist.github.com/undoZen/5806774 — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHubhttps://github.com/cloudhead/less.js/issues/1050#issuecomment-19622929 .

madcampos avatar Jun 18 '13 16:06 madcampos

+1... +2... +100... This is an incredibly important feature.

Prestaul avatar Jun 20 '13 22:06 Prestaul

+1

nbroslawsky avatar Jun 20 '13 22:06 nbroslawsky