postcss/sugarss

Space at the end of the line breaks sourcemap

akella opened this issue · 4 comments

Here is my gulpfile.js:

var gulp         = require('gulp');
var sugarss      = require('sugarss');
var sourcemaps   = require('gulp-sourcemaps');
var postcss      = require('gulp-postcss');

var processors = [];
gulp.task('sass', function() {
    return gulp
        .src('base.sss')
        .pipe(sourcemaps.init())
        .pipe(postcss(processors,{ parser: sugarss}))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('build'));
});

My test base.sss file:

body
    display: block 
    //              ^ extra space here

Here is what i get by running gulp sass:

[22:54:14] Starting 'sass'...

events.js:160
      throw er; // Unhandled 'error' event
      ^
Error: Invalid mapping: {"generated":{"line":2,"column":16},"source":"base.sss","original":{},"name":null}
    at SourceMapGenerator_validateMapping [as _validateMapping] (/Users/akella/Desktop/test/node_modules/source-map/lib/source-map-generator.js:277:13)
    at SourceMapGenerator_addMapping [as addMapping] (/Users/akella/Desktop/test/node_modules/source-map/lib/source-map-generator.js:101:12)
    at Stringifier.builder (/Users/akella/Desktop/test/node_modules/postcss/lib/map-generator.js:273:32)
    at Stringifier.decl (/Users/akella/Desktop/test/node_modules/postcss/lib/stringifier.js:58:14)
    at Stringifier.stringify (/Users/akella/Desktop/test/node_modules/postcss/lib/stringifier.js:35:24)
    at Stringifier.body (/Users/akella/Desktop/test/node_modules/postcss/lib/stringifier.js:95:18)
    at Stringifier.block (/Users/akella/Desktop/test/node_modules/postcss/lib/stringifier.js:105:18)
    at Stringifier.rule (/Users/akella%

When i remove that space, it works ok. With other parsers - it is also ok.
Test files http://take.ms/mcETr

ai commented

Thanks for good report. I will try to look at it on next week.

Just noticed that empty comment with space, breaks parser also

//
// ^ space here

May be you could check that out, sounds like the same reasoning behind that.

ai commented

Fixed ce2013d

ai commented

Released in 0.2.

Sorry for long delay, I loose myself in other opensource project :)