Skip to content

gulp-sourcemaps support #7

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

Closed
ksmithut opened this issue Nov 3, 2014 · 22 comments
Closed

gulp-sourcemaps support #7

ksmithut opened this issue Nov 3, 2014 · 22 comments

Comments

@ksmithut
Copy link

ksmithut commented Nov 3, 2014

Have you considered adding sourcemaps support?

@efolio
Copy link

efolio commented Dec 11, 2014

+1

@tracker1
Copy link
Member

@ksmithut do you have a suggestion how this would be supported? This module only changes the data for the outbound script file... if you have something that generates source maps, can't you just do it before this module?

@ksmithut
Copy link
Author

You can, but if you use this module after the sourcemaps, it will also add the header to the sourcemap file because the sourcemap is added to the pipeline. The gulp-sourcemaps plugin has some kind of API, but I personally haven't thought much about it.

Honestly, I was just wondering if you were going to think of supporting it. From what I understand about sourcemaps, its a very complex process, and even more so with a gulp workflow. If you don't plan on supporting (and I wouldn't blame you), go ahead and close this out.

I might have some time during the next few weeks to investigate if you would like.

@tracker1
Copy link
Member

If you can come up with a PR that doesn't add a dependency (other than the obvious dev dependency) with appropriate tests, I'll take the PR. I wish I had time to look into this (as well as a dozen other things)...

Been meaning to add sourcemaps into a couple projects I'm working on (in conjunction with es6 transpiling). I'm pretty test heavy, so haven't needed them so much, but when I have it would be really nice.

@dmitrijs
Copy link

+1

@ksmithut
Copy link
Author

@tracker1 In order to add sourcemap support, I'll need to add one dependency vinyl-sourcemaps-apply. If it's still not okay to add a dependency, I'll leave this to you or someone else. Seems like a pretty easy integration though with that module.

@tracker1
Copy link
Member

@contra @robrich @phated any input on this one?

@yocontra
Copy link
Member

Yep just use the standard gulp-sourcemaps (vinyl-sourcemaps-apply and whatever else) toolkit. There is info on how to add sourcemaps to your plugin on one of those pages.

@tracker1
Copy link
Member

@contra thanks for chiming in... @ksmithut if you generate a PR, I'm happy to add it, otherwise will probably get to this next week.

@ksmithut
Copy link
Author

@tracker1 I've jumped into sourcemap support, but I'm running into a few cases where sourcemaps might not make sense. What if someone adds code to the header to be consumed? How will that be mapped back? I mean, we could always include another file in the sourcemap, but that is turning out to be more complicated than I anticipated. This is really my first time working with generating sourcemaps.

I've looked through the documentation that @contra linked to, but it doesn't actually show how to apply the sourcemaps. The example assumes that the transformation plugin already has sourcemap support. Because this is simply prepending content onto the Buffer/Stream, we would need to write the sourcemap generator for this. Although it seems simple, this is really the first time I've done anything with sourcemap generation. If any of you have any links to resources on how to do this, I could try and muddle my way through it.

@tracker1
Copy link
Member

Looks like you should just be able to use gulp-sourcemaps

var gulp = require("gulp");
var sourcemaps = require("gulp-sourcemaps");
var header = require("gulp-header");
var headerText = require("fs").readSync(__dirname + "/txt/header.js", {encoding:utf8});

gulp.task("default", function () {
  return gulp.src(...)
    .pipe(sourcemaps.init())
    ......
    .pipe(header(headerText))
    .pipe(sourcemaps.write("."))
    .pipe(gulp.dest("dist"));
});

As to bringing in a header with code, I'd presume that you're probably going to concat, in which case, you can put the header at the beginning of your input thunk...

gulp.src([
  'header.js'
  ,'src/app/index.js'
])
.pipe(sourcemaps.init())
.pipe(concat())
...

@yocontra
Copy link
Member

@tracker1 No, using gulp-sourcemaps won't make sourcemaps start working. All gulp-sourcemaps does it take the file.sourceMaps array, flatten it down into one, and convert it to either a file or an inline comment. You should reopen this.

@tracker1 tracker1 reopened this Jan 16, 2015
@nervo
Copy link

nervo commented Jan 25, 2015

👍 on supporting sourcemaps

@knpwrs
Copy link

knpwrs commented Jan 31, 2015

👍 As well.

@kasperisager
Copy link

Just adding another 👍

@vrockai
Copy link

vrockai commented Mar 3, 2015

I've just left the gulp-header plugin today and used (ugly) gulp-concat workaround (just to prepend licence string) instead, only because of this issue. Big 👍 to resolving this.

@JeremyJames
Copy link

👍

@JeremyFagis
Copy link

👍 👍

@tracker1
Copy link
Member

tracker1 commented Mar 5, 2015

@vrockai any chance you could post your gulpfile with concat that is working... I haven't had a chance to dig through this, but will need it myself in a few weeks.

@vrockai
Copy link

vrockai commented Mar 5, 2015

@tracker1 , I'm just using temporary file; ugly, but working:
vrockai/hawkular-ui-components@83aac47#diff-b20c7230de4da834e815c06534cab810R124

@madhums
Copy link

madhums commented Aug 17, 2015

Sent a PR #16

maxyeg pushed a commit to twosigma/beakerx that referenced this issue Sep 16, 2015
 gulp-header version updated, it was fixed there in gulp-community/gulp-header#7
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