[Pkg-javascript-commits] [node-source-map-support] 01/05: New upstream version 0.4.9+ds

Julien Puydt julien.puydt at laposte.net
Mon Jan 16 20:54:22 UTC 2017


This is an automated email from the git hooks/post-receive script.

jpuydt-guest pushed a commit to branch master
in repository node-source-map-support.

commit 7a7c4c83c80195f7d2a9ec4c94b67014c25316dc
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Mon Jan 16 09:22:59 2017 +0100

    New upstream version 0.4.9+ds
---
 .gitignore            |  1 +
 build.js              | 10 ++++++++--
 package.json          |  5 +++--
 source-map-support.js | 42 ++++++++++++++++++++++++------------------
 test.js               |  8 ++++----
 5 files changed, 40 insertions(+), 26 deletions(-)

diff --git a/.gitignore b/.gitignore
index 19c622f..802b41f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@ browserify-test/script.js
 browserify-test/script.map
 header-test/script.js
 header-test/script.map
+webpack-test/compiled.js
\ No newline at end of file
diff --git a/build.js b/build.js
index fdbf145..998405c 100755
--- a/build.js
+++ b/build.js
@@ -5,8 +5,9 @@ var path = require('path');
 var querystring = require('querystring');
 var child_process = require('child_process');
 
-var browserify = path.join('node_modules', '.bin', 'browserify');
-var coffee = path.join('node_modules', '.bin', 'coffee');
+var browserify = path.resolve(path.join('node_modules', '.bin', 'browserify'));
+var webpack = path.resolve(path.join('node_modules', '.bin', 'webpack'));
+var coffee = path.resolve(path.join('node_modules', '.bin', 'coffee'));
 
 function run(command, callback) {
   console.log(command);
@@ -71,3 +72,8 @@ run(coffee + ' --map --compile header-test/script.coffee', function(error) {
   var contents = fs.readFileSync('header-test/script.js', 'utf8');
   fs.writeFileSync('header-test/script.js', contents.replace(/\/\/# sourceMappingURL=.*/g, ''))
 });
+
+// Build the webpack test
+child_process.exec(webpack, {cwd: 'webpack-test'}, function(error) {
+  if (error) throw error;
+});
diff --git a/package.json b/package.json
index 0f8bfdf..6056e13 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "source-map-support",
   "description": "Fixes stack traces for files with source maps",
-  "version": "0.4.8",
+  "version": "0.4.9",
   "main": "./source-map-support.js",
   "scripts": {
     "build": "node build.js",
@@ -16,7 +16,8 @@
     "browserify": "3.44.2",
     "coffee-script": "1.7.1",
     "http-server": "^0.8.5",
-    "mocha": "1.18.2"
+    "mocha": "1.18.2",
+    "webpack": "^1.13.3"
   },
   "repository": {
     "type": "git",
diff --git a/source-map-support.js b/source-map-support.js
index db36c41..5af4780 100644
--- a/source-map-support.js
+++ b/source-map-support.js
@@ -1,6 +1,12 @@
 var SourceMapConsumer = require('source-map').SourceMapConsumer;
 var path = require('path');
-var fs = require('fs');
+
+var fs;
+try {
+  fs = require('fs');
+} catch (err) {
+  /* nop */
+}
 
 // Only install once if called multiple times
 var errorFormatterInstalled = false;
@@ -58,24 +64,19 @@ retrieveFileHandlers.push(function(path) {
     return fileContentsCache[path];
   }
 
-  try {
+  var contents = null;
+  if (!fs) {
     // Use SJAX if we are in the browser
-    if (isInBrowser()) {
-      var xhr = new XMLHttpRequest();
-      xhr.open('GET', path, false);
-      xhr.send(null);
-      var contents = null
-      if (xhr.readyState === 4 && xhr.status === 200) {
-        contents = xhr.responseText
-      }
+    var xhr = new XMLHttpRequest();
+    xhr.open('GET', path, false);
+    xhr.send(null);
+    var contents = null
+    if (xhr.readyState === 4 && xhr.status === 200) {
+      contents = xhr.responseText
     }
-
+  } else if (fs.existsSync(path)) {
     // Otherwise, use the filesystem
-    else {
-      var contents = fs.readFileSync(path, 'utf8');
-    }
-  } catch (e) {
-    var contents = null;
+    contents = fs.readFileSync(path, 'utf8');
   }
 
   return fileContentsCache[path] = contents;
@@ -378,7 +379,7 @@ function getErrorSource(error) {
     var contents = fileContentsCache[source];
 
     // Support files on disk
-    if (!contents && fs.existsSync(source)) {
+    if (!contents && fs && fs.existsSync(source)) {
       contents = fs.readFileSync(source, 'utf8');
     }
 
@@ -460,7 +461,12 @@ exports.install = function(options) {
 
   // Support runtime transpilers that include inline source maps
   if (options.hookRequire && !isInBrowser()) {
-    var Module = require('module');
+    var Module;
+    try {
+      Module = require('module');
+    } catch (err) {
+      // NOP: Loading in catch block to convert webpack error to warning.
+    }
     var $compile = Module.prototype._compile;
 
     if (!$compile.__sourceMapSupport) {
diff --git a/test.js b/test.js
index 583dedd..5c28ba0 100644
--- a/test.js
+++ b/test.js
@@ -180,7 +180,7 @@ it('eval', function() {
     'Error: test',
 
     // Before Node 4, `Object.eval`, after just `eval`.
-    /^    at (?:Object\.)?eval \(eval at <anonymous> \((?:.*\/)?line1\.js:1001:101\)/,
+    /^    at (?:Object\.)?eval \(eval at (<anonymous>|exports.test) \((?:.*\/)?line1\.js:1001:101\)/,
 
     /^    at Object\.exports\.test \((?:.*\/)?line1\.js:1001:101\)$/
   ]);
@@ -191,8 +191,8 @@ it('eval inside eval', function() {
     'eval("eval(\'throw new Error(\\"test\\")\')");'
   ], [
     'Error: test',
-    /^    at (?:Object\.)?eval \(eval at <anonymous> \(eval at <anonymous> \((?:.*\/)?line1\.js:1001:101\)/,
-    /^    at (?:Object\.)?eval \(eval at <anonymous> \((?:.*\/)?line1\.js:1001:101\)/,
+    /^    at (?:Object\.)?eval \(eval at (<anonymous>|exports.test) \(eval at (<anonymous>|exports.test) \((?:.*\/)?line1\.js:1001:101\)/,
+    /^    at (?:Object\.)?eval \(eval at (<anonymous>|exports.test) \((?:.*\/)?line1\.js:1001:101\)/,
     /^    at Object\.exports\.test \((?:.*\/)?line1\.js:1001:101\)$/
   ]);
 });
@@ -227,7 +227,7 @@ it('eval with sourceURL inside eval', function() {
   ], [
     'Error: test',
     /^    at (?:Object\.)?eval \(sourceURL\.js:1:7\)$/,
-    /^    at (?:Object\.)?eval \(eval at <anonymous> \((?:.*\/)?line1\.js:1001:101\)/,
+    /^    at (?:Object\.)?eval \(eval at (<anonymous>|exports.test) \((?:.*\/)?line1\.js:1001:101\)/,
     /^    at Object\.exports\.test \((?:.*\/)?line1\.js:1001:101\)$/
   ]);
 });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-source-map-support.git



More information about the Pkg-javascript-commits mailing list