Skip to content

Commit

Permalink
testing inline and external source maps to ensure consistent behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdesl committed Apr 26, 2016
1 parent ded20f3 commit f3f10ae
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/require-hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = function requireHook (opts) {
var fs = remote.require('fs');
var stripBOM = require('strip-bom');
var combineSourceMap = require('combine-source-map');
var convertSourceMap = require('convert-source-map');
var browserResolve = require('browser-resolve');

var entry = opts.entry;
Expand Down Expand Up @@ -61,6 +62,13 @@ module.exports = function requireHook (opts) {

var wrapScript = moduleWrap(script);
if (!currentWrapFile) return wrapScript;

// If we have a source map pointing to a file, let Chrome handle it
if (convertSourceMap.mapFileCommentRegex.test(wrapScript)) {
return wrapScript;
}

// If we have inline source maps or none at all, we can use combine-source-map
var sourceFile = path.relative(basedir, currentWrapFile)
.replace(/\\/g, '/');
var sourceRoot = basedir;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"chokidar": "^1.4.2",
"combine-source-map": "^0.7.1",
"concat-stream": "^1.5.1",
"convert-source-map": "^1.2.0",
"deep-extend": "^0.4.1",
"electron-prebuilt": "^0.36.5",
"events": "^1.1.0",
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/inline-source-maps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var withBase64 = require('./source-map-base64.js');
var withMap = require('./source-map-external.js');
console.log(withBase64());
console.log(withMap.default());
20 changes: 20 additions & 0 deletions test/fixtures/source-map-base64.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions test/fixtures/source-map-external.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/fixtures/source-map-external.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f3f10ae

Please sign in to comment.