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

pathing issues in windows with node and babel #178

Open
amcdnl opened this issue Jan 6, 2016 · 2 comments
Open

pathing issues in windows with node and babel #178

amcdnl opened this issue Jan 6, 2016 · 2 comments

Comments

@amcdnl
Copy link

amcdnl commented Jan 6, 2016

I have the following script:

gulp.task('babel', function () {
  return gulp.src('./src/**/*.js')
    .pipe(sourcemaps.init())
    .pipe(babel())
    .pipe(sourcemaps.write('.', {
      includeContent: false,
      sourceRoot: function(file) {
        var from = file.path;
        var to = path.resolve(path.join(__dirname,'..', 'src'));
        var dest = path.join(path.relative(from, to), 'src');
        console.log('from %s\nto: %s\ndest: %s\n', from, to, dest);
        return dest;
      }
    }))
    .pipe(gulp.dest('./dist'));
});

and the following directory structure:

\src\api\application\ApplicationController.js
\dist ===> where things are transpiled to

and then I build it paths things correctly. ( source root pathing is done for this http://stackoverflow.com/questions/29170589/debug-nodejs-es6-app-webstorm ).

My output looks like this in the transpiled file:

//# sourceMappingURL=ApplicationController.js.map

and then in the map file ( i shorten for lack of space ) this:

sources":["api/application/ApplicationController.js"]
"sourceRoot":"..\\..\\..\\src"

here we can note that the paths for the sources is wrong for windows, however, I noticed you are manually switching it back for some reason on windows. https://github.com/floridoo/gulp-sourcemaps/blob/master/index.js#L365

When I open something like node-debug, I can see the paths getting resolved incorrectly like so: http://www.screencast.com/t/8nWrqRSjMSM

Any ideas whats going on?

@anyong
Copy link

anyong commented Mar 14, 2016

In case anyone else comes across this issue, the above function is returning the windows style path separators cause blink debugger to not be able to find them. Just replace

return dest;

with

return dest.split(path.sep).join('/');

and it works fine.

@phated
Copy link
Contributor

phated commented Mar 13, 2017

The result of this function call should be run through the unixStylePath helper. If anyone wants to send a PR, feel free.

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

No branches or pull requests

3 participants