module,src: do not wrap modules with -1 lineOffset
authorcjihrig <cjihrig@gmail.com>
Tue, 15 Dec 2015 22:37:16 +0000 (17:37 -0500)
committerMyles Borins <mborins@us.ibm.com>
Thu, 21 Jan 2016 01:06:01 +0000 (17:06 -0800)
In b799a74709af69daf13901390df9428c4c38adfc and
dfee4e3712ac4673b5fc472a8f77ac65bdc65f87 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: https://github.com/nodejs/node/issues/4297
PR-URL: https://github.com/nodejs/node/pull/4298
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
lib/module.js
src/node.js
test/sequential/test-module-loading.js

index 99c4762..1d937f8 100644 (file)
@@ -372,7 +372,7 @@ Module.prototype._compile = function(content, filename) {
   var wrapper = Module.wrap(content);
 
   var compiledWrapper = runInThisContext(wrapper,
-                                      { filename: filename, lineOffset: -1 });
+                                      { filename: filename, lineOffset: 0 });
   if (global.v8debug) {
     if (!resolvedArgv) {
       // we enter the repl if we're not given a filename argument.
index 367f68b..b38594f 100644 (file)
   };
 
   NativeModule.wrapper = [
-    '(function (exports, require, module, __filename, __dirname) {\n',
+    '(function (exports, require, module, __filename, __dirname) { ',
     '\n});'
   ];
 
 
     var fn = runInThisContext(source, {
       filename: this.filename,
-      lineOffset: -1
+      lineOffset: 0
     });
     fn(this.exports, NativeModule.require, this, this.filename);
 
index 19ba398..ead3447 100644 (file)
@@ -285,9 +285,9 @@ assert.equal(42, require('../fixtures/utf8-bom.js'));
 assert.equal(42, require('../fixtures/utf8-bom.json'));
 
 // Error on the first line of a module should
-// have the correct line and column number
+// have the correct line number
 assert.throws(function() {
   require('../fixtures/test-error-first-line-offset.js');
 }, function(err) {
-  return /test-error-first-line-offset.js:1:1/.test(err.stack);
+  return /test-error-first-line-offset.js:1:/.test(err.stack);
 }, 'Expected appearance of proper offset in Error stack');