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

Mixins with compound "&" selectors make sourcemaps invalid #2312

Closed
holmesmr opened this issue Feb 3, 2017 · 3 comments
Closed

Mixins with compound "&" selectors make sourcemaps invalid #2312

holmesmr opened this issue Feb 3, 2017 · 3 comments

Comments

@holmesmr
Copy link

holmesmr commented Feb 3, 2017

Under a specific set of conditions, compound selectors using &, such as &.mod-enabled or &:after, cause the sourcemap generator to produce sourcemaps with negative column indices.

The conditions are:

  • The rule must be a compound selector using the parent selector as above
  • The rule must be in the root of a mixin
  • The mixin must be included in the document at least 6 times

This popped up for me when gulp-sass switched to version 4.0 of node-sass, which pushed LibSass up to 3.4. Smallest reproducible test case I could make is available here.

Sample error:

Error: Invalid mapping: {"generated":{"line":1,"column":6},"source":"mixins.scss","original":{"line":3,"column":-4},"name":null}
    at SourceMapGenerator_validateMapping [as _validateMapping] (/Users/cepheus/break-gulp-sass/node_modules/source-map/lib/source-map-generator.js:277:13)
    at SourceMapGenerator_addMapping [as addMapping] (/Users/cepheus/break-gulp-sass/node_modules/source-map/lib/source-map-generator.js:101:12)
    at /Users/cepheus/break-gulp-sass/node_modules/concat-with-sourcemaps/index.js:60:28
    at Array.forEach (native)
    at SourceMapConsumer_eachMapping [as eachMapping] (/Users/cepheus/break-gulp-sass/node_modules/source-map/lib/source-map-consumer.js:155:14)
    at Concat.add (/Users/cepheus/break-gulp-sass/node_modules/concat-with-sourcemaps/index.js:58:18)
    at DestroyableTransform.bufferContents [as _transform] (/Users/cepheus/break-gulp-sass/node_modules/gulp-concat/index.js:68:12)
    at DestroyableTransform.Transform._read (/Users/cepheus/break-gulp-sass/node_modules/readable-stream/lib/_stream_transform.js:159:10)
    at DestroyableTransform.Transform._write (/Users/cepheus/break-gulp-sass/node_modules/readable-stream/lib/_stream_transform.js:147:83)
    at doWrite (/Users/cepheus/break-gulp-sass/node_modules/readable-stream/lib/_stream_writable.js:347:64)

A bisection of the test case revealed this issue was introduced in commit de83d30.

@holmesmr
Copy link
Author

holmesmr commented Feb 3, 2017

CCing in dlmanning/gulp-sass#577 so this issue is linked to that one.

@mgreter
Copy link
Contributor

mgreter commented Feb 3, 2017

Thanks for the test case, I can confirm the issue live from your repo with my sourcemap inspector.

grafik

@DBosley
Copy link

DBosley commented May 15, 2017

Getting an issue related to this combined with angular/material2's styles. Commenting here to raise awareness of the issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants