Import with media query and sourcemap enabled emits error
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 17k
- Forks
- 3.4k
- Avg merge
- 7h 42m
- Merged PRs (30d)
- 26
Description
Hello!
When compiling using lessc --source-map-map-inline index.less command following files
index.less
.test {
color: #000;
@import "in.less" only screen and (min-width: 1024);
}
in.less
a {
color: #ccc;
}
Error emitted by lessc:
TypeError: Cannot read property 'substring' of undefined
at SourceMapOutput.add (C:\Users\Fire\AppData\Roaming\npm\node_modules\less\lib\less\source-map-output.js:67:38)
at Element.genCSS (C:\Users\Fire\AppData\Roaming\npm\node_modules\less\lib\less\tree\element.js:35:12)
at Selector.genCSS (C:\Users\Fire\AppData\Roaming\npm\node_modules\less\lib\less\tree\selector.js:103:21)
at Ruleset.genCSS (C:\Users\Fire\AppData\Roaming\npm\node_modules\less\lib\less\tree\ruleset.js:386:21)
at Directive.outputRuleset (C:\Users\Fire\AppData\Roaming\npm\node_modules\less\lib\less\tree\directive.js:138:18)
at Media.genCSS (C:\Users\Fire\AppData\Roaming\npm\node_modules\less\lib\less\tree\media.js:32:10)
at Ruleset.genCSS (C:\Users\Fire\AppData\Roaming\npm\node_modules\less\lib\less\tree\ruleset.js:411:18)
at SourceMapOutput.toCSS (C:\Users\Fire\AppData\Roaming\npm\node_modules\less\lib\less\source-map-output.js:118:24)
at SourceMapBuilder.toCSS (C:\Users\Fire\AppData\Roaming\npm\node_modules\less\lib\less\source-map-builder.js:23:35)
at ParseTree.toCSS (C:\Users\Fire\AppData\Roaming\npm\node_modules\less\lib\less\parse-tree.js:33:47)
Without --source-map-map-inline parameter compilation runs normally.
Last not affected version is 2.4.0.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the shown index.less and in.less inputs using lessc --source-map-map-inline. Start by reading lib/less/source-map-output.js around SourceMapOutput.add and the related calls in tree/element.js and tree/media.js. Done means the media-query import compiles successfully with an inline sourcemap, while the existing normal compilation behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100