istanbul-lib-instrument
Advanced tools
Comparing version 4.0.0-alpha.1 to 4.0.0-alpha.2
@@ -6,2 +6,13 @@ # Change Log | ||
# [4.0.0-alpha.2](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-instrument@4.0.0-alpha.1...istanbul-lib-instrument@4.0.0-alpha.2) (2019-11-01) | ||
### Bug Fixes | ||
* Produce properly merged source-maps when inputSourceMap is provided ([#487](https://github.com/istanbuljs/istanbuljs/issues/487)) ([8f8c88e](https://github.com/istanbuljs/istanbuljs/commit/8f8c88e3a2add4c08729e41e356aa7981dc69d4d)) | ||
# [4.0.0-alpha.1](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-instrument@4.0.0-alpha.0...istanbul-lib-instrument@4.0.0-alpha.1) (2019-10-06) | ||
@@ -8,0 +19,0 @@ |
@@ -8,10 +8,4 @@ "use strict"; | ||
var parser = _interopRequireWildcard(require("@babel/parser")); | ||
var _core = require("@babel/core"); | ||
var t = _interopRequireWildcard(require("@babel/types")); | ||
var _traverse = _interopRequireDefault(require("@babel/traverse")); | ||
var _generator = _interopRequireDefault(require("@babel/generator")); | ||
var _schema = require("@istanbuljs/schema"); | ||
@@ -25,6 +19,2 @@ | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
/* | ||
@@ -82,44 +72,56 @@ Copyright 2012-2015, Yahoo Inc. | ||
filename = filename || String(new Date().getTime()) + '.js'; | ||
const opts = this.opts; | ||
const ast = parser.parse(code, { | ||
allowReturnOutsideFunction: opts.autoWrap, | ||
sourceType: opts.esModules ? 'module' : 'script', | ||
plugins: opts.parserPlugins | ||
}); | ||
const ee = (0, _visitor.default)(t, filename, { | ||
coverageVariable: opts.coverageVariable, | ||
coverageGlobalScope: opts.coverageGlobalScope, | ||
coverageGlobalScopeFunc: opts.coverageGlobalScopeFunc, | ||
ignoreClassMethods: opts.ignoreClassMethods, | ||
inputSourceMap | ||
}); | ||
const { | ||
opts | ||
} = this; | ||
let output = {}; | ||
const visitor = { | ||
Program: { | ||
enter: ee.enter, | ||
const babelOpts = { | ||
configFile: false, | ||
babelrc: false, | ||
ast: true, | ||
filename: filename || String(new Date().getTime()) + '.js', | ||
inputSourceMap, | ||
sourceMaps: opts.produceSourceMap, | ||
compact: opts.compact, | ||
comments: opts.preserveComments, | ||
parserOpts: { | ||
allowReturnOutsideFunction: opts.autoWrap, | ||
sourceType: opts.esModules ? 'module' : 'script', | ||
plugins: opts.parserPlugins | ||
}, | ||
plugins: [[({ | ||
types | ||
}) => { | ||
const ee = (0, _visitor.default)(types, filename, { | ||
coverageVariable: opts.coverageVariable, | ||
coverageGlobalScope: opts.coverageGlobalScope, | ||
coverageGlobalScopeFunc: opts.coverageGlobalScopeFunc, | ||
ignoreClassMethods: opts.ignoreClassMethods, | ||
inputSourceMap | ||
}); | ||
return { | ||
visitor: { | ||
Program: { | ||
enter: ee.enter, | ||
exit(path) { | ||
output = ee.exit(path); | ||
} | ||
exit(path) { | ||
output = ee.exit(path); | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
}]] | ||
}; | ||
(0, _traverse.default)(ast, visitor); | ||
const generateOptions = { | ||
compact: opts.compact, | ||
comments: opts.preserveComments, | ||
sourceMaps: opts.produceSourceMap, | ||
sourceFileName: filename | ||
}; | ||
const codeMap = (0, _generator.default)(ast, generateOptions, code); | ||
const codeMap = (0, _core.transformSync)(code, babelOpts); | ||
if (output && output.fileCoverage) { | ||
this.fileCoverage = output.fileCoverage; | ||
} else { | ||
const initialCoverage = (0, _readCoverage.default)(ast) || | ||
if (!output || !output.fileCoverage) { | ||
const initialCoverage = (0, _readCoverage.default)(codeMap.ast) || | ||
/* istanbul ignore next: paranoid check */ | ||
{}; | ||
this.fileCoverage = initialCoverage.coverageData; | ||
this.sourceMap = inputSourceMap; | ||
return code; | ||
} | ||
this.fileCoverage = output.fileCoverage; | ||
this.sourceMap = codeMap.map; | ||
@@ -126,0 +128,0 @@ const cb = this.opts.sourceMapUrlCallback; |
@@ -12,4 +12,2 @@ "use strict"; | ||
var t = _interopRequireWildcard(require("@babel/types")); | ||
var _schema = require("@istanbuljs/schema"); | ||
@@ -19,6 +17,2 @@ | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -55,3 +49,3 @@ | ||
if (!node.computed && t.isIdentifier(node.key) && node.key.name === _constants.MAGIC_KEY) { | ||
if (!node.computed && path.get('key').isIdentifier() && node.key.name === _constants.MAGIC_KEY) { | ||
const magicValue = path.get('value').evaluate(); | ||
@@ -58,0 +52,0 @@ |
{ | ||
"name": "istanbul-lib-instrument", | ||
"version": "4.0.0-alpha.1", | ||
"version": "4.0.0-alpha.2", | ||
"description": "Core istanbul API for JS code coverage", | ||
@@ -16,7 +16,6 @@ "author": "Krishnan Anantheswaran <kananthmail-github@yahoo.com>", | ||
"dependencies": { | ||
"@babel/generator": "^7.6.2", | ||
"@babel/core": "^7.6.2", | ||
"@babel/parser": "^7.6.2", | ||
"@babel/template": "^7.6.0", | ||
"@babel/traverse": "^7.6.2", | ||
"@babel/types": "^7.6.1", | ||
"@istanbuljs/schema": "^0.1.0", | ||
@@ -28,3 +27,2 @@ "istanbul-lib-coverage": "^3.0.0-alpha.1", | ||
"@babel/cli": "^7.6.2", | ||
"@babel/core": "^7.6.2", | ||
"@babel/plugin-transform-modules-commonjs": "^7.6.0", | ||
@@ -60,3 +58,3 @@ "@babel/register": "^7.6.2", | ||
}, | ||
"gitHead": "4d5e777a9bc4847d178ad31f379307124cdd1e4f" | ||
"gitHead": "7c1367b5786fd6378aa0f3920386672a15edac71" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7
11
56459
+ Added@babel/core@^7.6.2
+ Added@ampproject/remapping@2.3.0(transitive)
+ Added@babel/compat-data@7.25.4(transitive)
+ Added@babel/core@7.25.2(transitive)
+ Added@babel/helper-compilation-targets@7.25.2(transitive)
+ Added@babel/helper-module-imports@7.24.7(transitive)
+ Added@babel/helper-module-transforms@7.25.2(transitive)
+ Added@babel/helper-simple-access@7.24.7(transitive)
+ Added@babel/helper-validator-option@7.24.8(transitive)
+ Added@babel/helpers@7.25.6(transitive)
+ Addedbrowserslist@4.24.0(transitive)
+ Addedcaniuse-lite@1.0.30001664(transitive)
+ Addedconvert-source-map@2.0.0(transitive)
+ Addedelectron-to-chromium@1.5.29(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedgensync@1.0.0-beta.2(transitive)
+ Addedjson5@2.2.3(transitive)
+ Addedlru-cache@5.1.1(transitive)
+ Addednode-releases@2.0.18(transitive)
+ Addedupdate-browserslist-db@1.1.1(transitive)
+ Addedyallist@3.1.1(transitive)
- Removed@babel/generator@^7.6.2
- Removed@babel/types@^7.6.1