Skip to content

Commit

Permalink
Use inline source maps in development
Browse files Browse the repository at this point in the history
There is currently a bug in chrome that prevents reading source maps
from a local file [0]. This was preventing Chrome DevTools from using
our JavaScript source maps, where were saved as `.map` files. To work
around this problem the source maps are now generated inline, which
seems to work fine.

The only other browser I tested this with was Firefox, which works both
before and after this change.

[0]: https://bugs.chromium.org/p/chromium/issues/detail?id=931675
  • Loading branch information
Gudahtt committed Jun 26, 2019
1 parent 76e7c3b commit 374171b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ function createTasksForBuildJsExtension ({ buildJsFiles, taskPrefix, devMode, te
const destinations = browserPlatforms.map(platform => `./dist/${platform}`)
bundleTaskOpts = Object.assign({
buildSourceMaps: true,
sourceMapDir: devMode ? './' : '../sourcemaps',
sourceMapDir: '../sourcemaps',
minifyBuild: !devMode,
buildWithFullPaths: devMode,
watch: devMode,
Expand Down Expand Up @@ -604,10 +604,17 @@ function bundleTask (opts) {
}))
}

// Finalize Source Maps (writes .map file)
// Finalize Source Maps
if (opts.buildSourceMaps) {
buildStream = buildStream
.pipe(sourcemaps.write(opts.sourceMapDir))
if (opts.devMode) {
// Use inline source maps for development due to Chrome DevTools bug
// https://bugs.chromium.org/p/chromium/issues/detail?id=931675
buildStream = buildStream
.pipe(sourcemaps.write())
} else {
buildStream = buildStream
.pipe(sourcemaps.write(opts.sourceMapDir))
}
}

// write completed bundles
Expand Down

0 comments on commit 374171b

Please sign in to comment.