Skip to content

Commit 2a60e2a

Browse files
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 4b267df commit 2a60e2a

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
@@ -958,7 +958,7 @@
958958
};
959959

960960
NativeModule.wrapper = [
961-
'(function (exports, require, module, __filename, __dirname) {\n',
961+
'(function (exports, require, module, __filename, __dirname) { ',
962962
'\n});'
963963
];
964964

@@ -968,7 +968,7 @@
968968

969969
var fn = runInThisContext(source, {
970970
filename: this.filename,
971-
lineOffset: -1
971+
lineOffset: 0
972972
});
973973
fn(this.exports, NativeModule.require, this, this.filename);
974974

test/sequential/test-module-loading.js

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

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

0 commit comments

Comments
 (0)