gulp-replace icon indicating copy to clipboard operation
gulp-replace copied to clipboard

Sourcemap support?

Open davidtheclark opened this issue 10 years ago • 12 comments

Should this plugin work with gulp-sourcemaps?

I'm asking because in my case it doesn't seem to --- the addition of this plugin into my stream makes the sourcemaps inaccurate.

I see no mention of "sourcemap" in the repo; so before I dug deeper I just wanted to check: Has any effort already been made to support sourcemaps with this plugin? Maybe I am missing something?

davidtheclark avatar Jan 19 '15 17:01 davidtheclark

Hmm, can you paste your gulp task so we can take a look?

lazd avatar Jan 21 '15 19:01 lazd

It's a little bit odd because it starts with a Browserify bundle:

function bundleApp(b, cb) {
    cb = cb || _.noop;

    return b.bundle()
        .on('error', function(err) { console.error(err); })
        .pipe(vinylSourceStream('htcInit.js'))
        .pipe(vinylBuffer())
        .pipe(gSourcemaps.init({ loadMaps: true }))
        .pipe(gIf(cliOptions.nodevlog || cliOptions.dist, gReplace(devlogRegExp, '')))
        .pipe(gSourcemaps.write())
        .pipe(gulp.dest(jsDestDir))
        .on('end', cb);
}

gulp.task('js:dev', function(cb) {
    var appBundler = browserify(jsEntry, options.browserify)
        .external(vendorLibs)
        .transform(to5ify);
    bundleApp(appBundler, cb);
});

Seems that if I leave out the line that calls gReplace(), although the end result has accurate sourcemaps; but when I add it in, sourcemaps break. Maybe it's a mistake in how I'm piping things together, dealing with Browserify streams vs. vinyl streams, etc.

davidtheclark avatar Jan 21 '15 19:01 davidtheclark

Yeah, I could see how this would break things -- the source map won't match after we replace. I wonder how much work it would take to add support...

lazd avatar Jan 21 '15 19:01 lazd

Ok, so that's not a situation that's already been taken into account. If I have the chance I'll try to look into it. And of course if you @lazd or someone else can add that support, that would be grand. Thanks.

davidtheclark avatar Jan 21 '15 19:01 davidtheclark

I was hoping there would be some built-in Gulp way to make sourcemaps like magic, but I don't think there is, right? gulp-sourcemaps basically says that each plugin is responsible for creating its own sourcemaps. I have no idea how to do that, so can't promise any timely help here.

davidtheclark avatar Jan 22 '15 01:01 davidtheclark

any updates? :/

stryju avatar Jul 24 '15 12:07 stryju

@lazd found anyone yet who could add support for this? I've been looking into it myself but at the moment I haven't got time to really put the necessary effort in...

call-a3 avatar Sep 03 '15 09:09 call-a3

@call-a3 unfortunately no, and I don't have time myself :-/

lazd avatar Sep 03 '15 14:09 lazd

regexp-sourcemaps may be helpful to generate sourcemaps

otakustay avatar Jul 23 '16 09:07 otakustay

I've also run into this when refactoring the Semantic UI build pipeline to use sourcemaps.

Guidance on how to add sourcemap support for gulp plugins can be found here

jlukic avatar Dec 19 '16 00:12 jlukic

Any update on this? This is the last gulp plugin we are relying on that needs sourcemap support. Other plugins that have it are listed here.

westy92 avatar Jun 05 '17 21:06 westy92

No update, but PRs gladly accepted.

On Mon, Jun 5, 2017 at 2:10 PM, Seth Westphal [email protected] wrote:

Any update on this? This is the last gulp plugin we are relying on that needs sourcemap support. Other plugins that have it are listed here https://github.com/gulp-sourcemaps/gulp-sourcemaps/wiki/Plugins-with-gulp-sourcemaps-support .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lazd/gulp-replace/issues/37#issuecomment-306311265, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMSgMTQehdTNC9sxjjTYYJHemcd8xMxks5sBG7BgaJpZM4DUQtU .

lazd avatar Jun 05 '17 23:06 lazd