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

Source Maps Has No Mapping for a Closing Bracket #3484

Closed
BrianMulhall opened this issue Mar 1, 2020 · 4 comments
Closed

Source Maps Has No Mapping for a Closing Bracket #3484

BrianMulhall opened this issue Mar 1, 2020 · 4 comments
Labels
Milestone

Comments

@BrianMulhall
Copy link

BrianMulhall commented Mar 1, 2020

When i generate a source map for the following file using version 3.11.1

.example {
  display: grid;
  transition: all 0.5s;
  user-select: none;
  background: linear-gradient(to bottom, white, black);
}

@color: "blue";

#my-div {
  color: @color;
}

with the following command in a node script

less.render(lessFileContents, { sourceMap: { sourceMapFileInline: false } })
  .then(function (output) {},

Then i look at the Source Map and run it in the https://sokra.github.io/source-map-visualization/#custom tool

{"version":3,"sources":["input"],"names":[],"mappings":"AAAA;EACE,aAAA;EACA,oBAAA;EACA,iBAAA;EACA,YAAY,wCAAZ;;AAKF;EACE,OAHM,MAGN"}

You can see the empty line in between these two mappings wCAAZ;;AAKF where the mapping for the } should be. This becomes and issue when you are making a source map where this generated map is an intermediate step that you are using to get back to the original Less file.

As an update I have tried Stylus and node-sass and they all do not have a mapping for the closing brackets in the generated file back to the original files. Is this just a limitation of pre processors in general?

@matthew-dean
Copy link
Member

matthew-dean commented Mar 4, 2020

The simple answer is that Less (currently) has a very simple parser that only tracks source start and not source end, mostly because it was created before source maps were a concept.

I've been re-writing a Less parser from scratch using Chevrotain to use for 4.x, and have done a significant amount of work on it, but without financial support (a la Open Collective), I can really only work on it in limited free time. I still intend to, but it might take a while.

@BrianMulhall
Copy link
Author

BrianMulhall commented Mar 4, 2020

that makes alot of sense, thanks for the quick response. Ill make a contribution to the open collective on friday. Im excited about the new parser now that I know its coming in the future. I signed up as a monthly contributor and made an announcement in the Meteor Slack channel and on LinkedIn. I will keep trying to gather support for LESS as well moving forward. Its one of my favorite projects

@BarbzYHOOL
Copy link

just wanted to say that Less is awesome

@matthew-dean matthew-dean added this to the 4.0 milestone Apr 30, 2020
@stale
Copy link

stale bot commented Aug 29, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 29, 2020
@stale stale bot closed this as completed Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants