kunalkapadia / express-mongoose-es6-rest-api

:collision: A boilerplate application for building RESTful APIs Microservice in Node.js using express and mongoose in ES6 with code coverage and JsonWebToken Authentication
http://kunalkapadia.github.io/express-mongoose-es6-rest-api/
MIT License
2.94k stars 695 forks source link

Source map path for node-inspector #232

Open simonschllng opened 7 years ago

simonschllng commented 7 years ago

Running node-inspector is currently not possible in this project. The reason for this is that the paths in the sourcemaps are incorrect. To validate I cloned the project and committed the dist folder. The result is: https://sourcemaps.io/validate?url=https%3A%2F%2Fgithub.com%2Fsimonschllng%2Fexpress-mongoose-es6-rest-api-ts%2Fraw%2Fsourcemaps%2Fdist%2Fserver%2Fcontrollers%2Fauth.controller.js

Unable to fetch sources in https://github.com/simonschllng/express-mongoose-es6-rest-api-ts/raw/sourcemaps/dist/server/controllers/auth.controller.js.map

Error: https://github.com/simonschllng/express-mongoose-es6-rest-api-ts/server/controllers/auth.controller.js (404)

In dist/server/controllers/auth.controller.js.map the sourcefile is defined as: {"version":3,"sources":["server/controllers/auth.controller.js"]

Source maps are generated in gulpfile.babel.js#L33:

// Compile ES6 to ES5 and copy to dist
gulp.task('babel', () =>
  gulp.src([...paths.js, '!gulpfile.babel.js'], { base: '.' })
    .pipe(plugins.newer('dist'))
    .pipe(plugins.sourcemaps.init())
    .pipe(plugins.babel())
    .pipe(plugins.sourcemaps.write('.', {
      includeContent: false,
      sourceRoot(file) {
        return path.relative(file.path, __dirname);
      }
    }))
    .pipe(gulp.dest('dist'))
);

Following the source maps spec, the sourceRoot() function is optional. It sets the path. However, removing it does not solve the problem.

Why is the sourceRoot() function used? How can we fix the source maps?

sanketmaru commented 7 years ago

I want to use node-inspector to debug the code. Is this possible in this project ?