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

Generates incorrect source map when one of the source vinyls has no sourceMap #94

Closed
insidewhy opened this issue May 12, 2015 · 7 comments

Comments

@insidewhy
Copy link

e.g.:

var gulp       = require('gulp')
var traceur    = require('gulp-traceur')
var sourcemaps = require('gulp-sourcemaps')
var concat     = require('gulp-concat')
var merge      = require('merge-stream')

gulp.task('default', function() {
  merge(
    gulp.src(['app/*.js', 'app/*/*.js']).pipe(sourcemaps.init()).pipe(traceur())
    gulp.src('bootstrap.js').pipe(sourcemaps.init())
  )
  .pipe(concat('output.js'))
  .pipe(sourcemaps.write())
  .pipe(gulp.dest('dist/assets'))
})

The vinyl for bootstrap.js has an empty source map attached by this line of code:

https://github.com/floridoo/gulp-sourcemaps/blob/master/index.js#L107

gulp-concat should detect empty source maps and replace them with identity source maps. Either this or that line there could be changed to attach an identity source map instead of an empty source map.

sigh takes the former approach as it's slightly more efficient and abstracts it behind the source map API. With that small change then gulp-concat will produce correct source maps :)

Here is a code sample that shows how to generate identity source maps.

First reported in gulpjs/gulp#843 (comment)

@insidewhy insidewhy changed the title Generates incorrect source map when one of the source vinyl's has no sourceMap Generates incorrect source map when one of the source vinyls has no sourceMap May 12, 2015
@yocontra
Copy link
Member

I think this should be done in gulp-sourcemaps not in each plugin

@insidewhy
Copy link
Author

It wouldn't need to be in each plugin, just in gulp-concat. I don't think any other plugins mind if they get an empty source map. To generate the identity map you'll need to parse the source code with something like esprima which might seem a bit heavy considering they aren't needed in most cases.

@yocontra
Copy link
Member

other option is handling it in concat-with-sourcemaps but it should not be in gulp-concat

@insidewhy
Copy link
Author

Okay I'll leave you to open the bug against concat-with-sourcemaps. This being an issue for the last few years is kinda what made me decide to compete with gulp and write a new asset pipeline, I really hope you can fix it, I want good competition to drive my own work forwards!

@yocontra
Copy link
Member

@ohjames last couple years? gulp-sourcemaps is like less than 1yr old and gulp is still a pretty new project

@insidewhy
Copy link
Author

Surprised, feels like years.

On 13 May 2015 19:49:01 BST, contra notifications@github.com wrote:

@ohjames last couple years? gulp-sourcemaps is like less than 1yr old
and gulp is still a pretty new project


Reply to this email directly or view it on GitHub:
#94 (comment)

@yocontra
Copy link
Member

@ohjames Bugs can't get fixed if nobody opens a ticket. Your fault for not opening a ticket when you encountered a bug.

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

No branches or pull requests

2 participants