6to5
Advanced tools
Comparing version 3.3.3 to 3.3.4
@@ -182,3 +182,3 @@ "use strict"; | ||
if (opts.before) opts.before(); | ||
this.map.mark(node, "start"); | ||
this.map.mark(node); | ||
@@ -193,3 +193,2 @@ this[node.type](node, this.buildPrint(node), parent); | ||
this.map.mark(node, "end"); | ||
if (opts.after) opts.after(); | ||
@@ -196,0 +195,0 @@ |
@@ -33,3 +33,3 @@ "use strict"; | ||
SourceMap.prototype.mark = function (node, type) { | ||
SourceMap.prototype.mark = function (node) { | ||
var loc = node.loc; | ||
@@ -50,6 +50,4 @@ if (!loc) return; // no location info | ||
var original = loc[type]; | ||
var original = loc.start; | ||
if (generated.line === original.line && generated.column === original.column) return; // nothing to map | ||
map.addMapping({ | ||
@@ -56,0 +54,0 @@ source: this.opts.sourceFileName, |
@@ -37,6 +37,4 @@ "use strict"; | ||
var onlyRegex; | ||
var whitelist = []; | ||
var exts = {}; | ||
var maps = {}; | ||
var old = require.extensions[".js"]; | ||
@@ -47,7 +45,3 @@ var mtime = function (filename) { | ||
var loader = function (m, filename) { | ||
if ((ignoreRegex && ignoreRegex.test(filename)) || (onlyRegex && !onlyRegex.test(filename))) { | ||
return old.apply(this, arguments); | ||
} | ||
var compile = function (filename) { | ||
var result; | ||
@@ -62,7 +56,8 @@ | ||
result = result || to5.transformFileSync(filename, extend({ | ||
whitelist: whitelist, | ||
sourceMap: true, | ||
ast: false | ||
}, transformOpts)); | ||
if (!result) { | ||
result = to5.transformFileSync(filename, extend({ | ||
sourceMap: true, | ||
ast: false | ||
}, transformOpts)); | ||
} | ||
@@ -76,5 +71,41 @@ if (cache) { | ||
m._compile(result.code, filename); | ||
return result.code; | ||
}; | ||
var shouldIgnore = function (filename) { | ||
return (ignoreRegex && ignoreRegex.test(filename)) || (onlyRegex && !onlyRegex.test(filename)); | ||
}; | ||
var istanbulLoader = function (m, filename, old) { | ||
// we need to monkey patch fs.readFileSync so we can hook into | ||
// what istanbul gets, it's extremely dirty but it's the only way | ||
var _readFileSync = fs.readFileSync; | ||
fs.readFileSync = function () { | ||
fs.readFileSync = _readFileSync; | ||
return compile(filename); | ||
}; | ||
old(m, filename); | ||
}; | ||
var normalLoader = function (m, filename) { | ||
m._compile(compile(filename), filename); | ||
}; | ||
var registerExtension = function (ext) { | ||
var old = require.extensions[ext]; | ||
var loader = normalLoader; | ||
if (process.env.running_under_istanbul) loader = istanbulLoader; // jshint ignore:line | ||
require.extensions[ext] = function (m, filename) { | ||
if (shouldIgnore(filename)) { | ||
old(m, filename); | ||
} else { | ||
loader(m, filename, old); | ||
} | ||
}; | ||
}; | ||
var hookExtensions = function (_exts) { | ||
@@ -89,3 +120,3 @@ each(exts, function (old, ext) { | ||
exts[ext] = require.extensions[ext]; | ||
require.extensions[ext] = loader; | ||
registerExtension(ext); | ||
}); | ||
@@ -92,0 +123,0 @@ }; |
@@ -15,3 +15,2 @@ module.exports = { | ||
react: require("./other/react"), | ||
"optimisation.react": require("./optimisation/react"), | ||
@@ -18,0 +17,0 @@ _modules: require("./internal/modules"), |
{ | ||
"name": "6to5", | ||
"description": "Turn ES6 code into readable vanilla ES5 with source maps", | ||
"version": "3.3.3", | ||
"version": "3.3.4", | ||
"author": "Sebastian McKenzie <sebmck@gmail.com>", | ||
@@ -6,0 +6,0 @@ "homepage": "https://6to5.org/", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1391728
141
11800
42