Skip to content

Commit 1408f7a

Browse files
cjihrigMyles Borins
authored and
Myles Borins
committed
module,src: do not wrap modules with -1 lineOffset
In b799a74 and dfee4e3 the module wrapping mechanism was changed for better error reporting. However, the changes causes issues with debuggers and profilers. This commit reverts the wrapping changes. Fixes: #4297 PR-URL: #4298 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Ali Ijaz Sheikh <[email protected]>
1 parent 8a0cc64 commit 1408f7a

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lib/module.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ Module.prototype._compile = function(content, filename) {
372372
var wrapper = Module.wrap(content);
373373

374374
var compiledWrapper = runInThisContext(wrapper,
375-
{ filename: filename, lineOffset: -1 });
375+
{ filename: filename, lineOffset: 0 });
376376
if (global.v8debug) {
377377
if (!resolvedArgv) {
378378
// we enter the repl if we're not given a filename argument.

src/node.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@
942942
};
943943

944944
NativeModule.wrapper = [
945-
'(function (exports, require, module, __filename, __dirname) {\n',
945+
'(function (exports, require, module, __filename, __dirname) { ',
946946
'\n});'
947947
];
948948

@@ -952,7 +952,7 @@
952952

953953
var fn = runInThisContext(source, {
954954
filename: this.filename,
955-
lineOffset: -1
955+
lineOffset: 0
956956
});
957957
fn(this.exports, NativeModule.require, this, this.filename);
958958

test/sequential/test-module-loading.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,9 @@ assert.equal(42, require('../fixtures/utf8-bom.js'));
285285
assert.equal(42, require('../fixtures/utf8-bom.json'));
286286

287287
// Error on the first line of a module should
288-
// have the correct line and column number
288+
// have the correct line number
289289
assert.throws(function() {
290290
require('../fixtures/test-error-first-line-offset.js');
291291
}, function(err) {
292-
return /test-error-first-line-offset.js:1:1/.test(err.stack);
292+
return /test-error-first-line-offset.js:1:/.test(err.stack);
293293
}, 'Expected appearance of proper offset in Error stack');

0 commit comments

Comments
 (0)