babel-jest
Advanced tools
Comparing version 29.7.0 to 30.0.0-alpha.1
@@ -1,9 +0,82 @@ | ||
'use strict'; | ||
/*! | ||
* /** | ||
* * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* * | ||
* * This source code is licensed under the MIT license found in the | ||
* * LICENSE file in the root directory of this source tree. | ||
* * / | ||
*/ | ||
/******/ (() => { // webpackBootstrap | ||
/******/ "use strict"; | ||
/******/ var __webpack_modules__ = ({ | ||
Object.defineProperty(exports, '__esModule', { | ||
/***/ "./src/loadBabelConfig.ts": | ||
/***/ ((__unused_webpack_module, exports) => { | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
}); | ||
exports.default = exports.createTransformer = void 0; | ||
})); | ||
Object.defineProperty(exports, "loadPartialConfig", ({ | ||
enumerable: true, | ||
get: function () { | ||
return _core().loadPartialConfig; | ||
} | ||
})); | ||
Object.defineProperty(exports, "loadPartialConfigAsync", ({ | ||
enumerable: true, | ||
get: function () { | ||
return _core().loadPartialConfigAsync; | ||
} | ||
})); | ||
function _core() { | ||
const data = require("@babel/core"); | ||
_core = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
/***/ }) | ||
/******/ }); | ||
/************************************************************************/ | ||
/******/ // The module cache | ||
/******/ var __webpack_module_cache__ = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ var cachedModule = __webpack_module_cache__[moduleId]; | ||
/******/ if (cachedModule !== undefined) { | ||
/******/ return cachedModule.exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = __webpack_module_cache__[moduleId] = { | ||
/******/ // no module.id needed | ||
/******/ // no module.loaded needed | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/************************************************************************/ | ||
var __webpack_exports__ = {}; | ||
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. | ||
(() => { | ||
var exports = __webpack_exports__; | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
})); | ||
exports["default"] = exports.createTransformer = void 0; | ||
function _crypto() { | ||
const data = require('crypto'); | ||
const data = require("crypto"); | ||
_crypto = function () { | ||
@@ -15,3 +88,3 @@ return data; | ||
function path() { | ||
const data = _interopRequireWildcard(require('path')); | ||
const data = _interopRequireWildcard(require("path")); | ||
path = function () { | ||
@@ -23,3 +96,3 @@ return data; | ||
function _core() { | ||
const data = require('@babel/core'); | ||
const data = require("@babel/core"); | ||
_core = function () { | ||
@@ -31,3 +104,3 @@ return data; | ||
function _chalk() { | ||
const data = _interopRequireDefault(require('chalk')); | ||
const data = _interopRequireDefault(require("chalk")); | ||
_chalk = function () { | ||
@@ -39,3 +112,3 @@ return data; | ||
function fs() { | ||
const data = _interopRequireWildcard(require('graceful-fs')); | ||
const data = _interopRequireWildcard(require("graceful-fs")); | ||
fs = function () { | ||
@@ -47,3 +120,3 @@ return data; | ||
function _slash() { | ||
const data = _interopRequireDefault(require('slash')); | ||
const data = _interopRequireDefault(require("slash")); | ||
_slash = function () { | ||
@@ -54,46 +127,6 @@ return data; | ||
} | ||
var _loadBabelConfig = require('./loadBabelConfig'); | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _getRequireWildcardCache(nodeInterop) { | ||
if (typeof WeakMap !== 'function') return null; | ||
var cacheBabelInterop = new WeakMap(); | ||
var cacheNodeInterop = new WeakMap(); | ||
return (_getRequireWildcardCache = function (nodeInterop) { | ||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop; | ||
})(nodeInterop); | ||
} | ||
function _interopRequireWildcard(obj, nodeInterop) { | ||
if (!nodeInterop && obj && obj.__esModule) { | ||
return obj; | ||
} | ||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { | ||
return {default: obj}; | ||
} | ||
var cache = _getRequireWildcardCache(nodeInterop); | ||
if (cache && cache.has(obj)) { | ||
return cache.get(obj); | ||
} | ||
var newObj = {}; | ||
var hasPropertyDescriptor = | ||
Object.defineProperty && Object.getOwnPropertyDescriptor; | ||
for (var key in obj) { | ||
if (key !== 'default' && 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; | ||
} | ||
var _loadBabelConfig = __webpack_require__("./src/loadBabelConfig.ts"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
/** | ||
@@ -111,9 +144,3 @@ * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
if (!babelConfig) { | ||
throw new Error( | ||
`babel-jest: Babel ignores ${_chalk().default.bold( | ||
(0, _slash().default)(path().relative(cwd, filename)) | ||
)} - make sure to include the file in Jest's ${_chalk().default.bold( | ||
'transformIgnorePatterns' | ||
)} as well.` | ||
); | ||
throw new Error(`babel-jest: Babel ignores ${_chalk().default.bold((0, _slash().default)(path().relative(cwd, filename)))} - make sure to include the file in Jest's ${_chalk().default.bold('transformIgnorePatterns')} as well.`); | ||
} | ||
@@ -128,12 +155,7 @@ } | ||
// Copied from jest-runtime transform.js | ||
copiedBabelOptions.plugins = (copiedBabelOptions.plugins ?? []).concat([ | ||
[ | ||
babelIstanbulPlugin, | ||
{ | ||
// files outside `cwd` will not be instrumented | ||
cwd: transformOptions.config.cwd, | ||
exclude: [] | ||
} | ||
] | ||
]); | ||
copiedBabelOptions.plugins = (copiedBabelOptions.plugins ?? []).concat([[babelIstanbulPlugin, { | ||
// files outside `cwd` will not be instrumented | ||
cwd: transformOptions.config.cwd, | ||
exclude: [] | ||
}]]); | ||
return copiedBabelOptions; | ||
@@ -143,32 +165,10 @@ } | ||
} | ||
function getCacheKeyFromConfig( | ||
sourceText, | ||
sourcePath, | ||
babelOptions, | ||
transformOptions | ||
) { | ||
const {config, configString, instrument} = transformOptions; | ||
function getCacheKeyFromConfig(sourceText, sourcePath, babelOptions, transformOptions) { | ||
const { | ||
config, | ||
configString, | ||
instrument | ||
} = transformOptions; | ||
const configPath = [babelOptions.config ?? '', babelOptions.babelrc ?? '']; | ||
return (0, _crypto().createHash)('sha1') | ||
.update(THIS_FILE) | ||
.update('\0', 'utf8') | ||
.update(JSON.stringify(babelOptions.options)) | ||
.update('\0', 'utf8') | ||
.update(sourceText) | ||
.update('\0', 'utf8') | ||
.update(path().relative(config.rootDir, sourcePath)) | ||
.update('\0', 'utf8') | ||
.update(configString) | ||
.update('\0', 'utf8') | ||
.update(configPath.join('')) | ||
.update('\0', 'utf8') | ||
.update(instrument ? 'instrument' : '') | ||
.update('\0', 'utf8') | ||
.update(process.env.NODE_ENV ?? '') | ||
.update('\0', 'utf8') | ||
.update(process.env.BABEL_ENV ?? '') | ||
.update('\0', 'utf8') | ||
.update(process.version) | ||
.digest('hex') | ||
.substring(0, 32); | ||
return (0, _crypto().createHash)('sha1').update(THIS_FILE).update('\0', 'utf8').update(JSON.stringify(babelOptions.options)).update('\0', 'utf8').update(sourceText).update('\0', 'utf8').update(path().relative(config.rootDir, sourcePath)).update('\0', 'utf8').update(configString).update('\0', 'utf8').update(configPath.join('')).update('\0', 'utf8').update(instrument ? 'instrument' : '').update('\0', 'utf8').update("production" ?? 0).update('\0', 'utf8').update(process.env.BABEL_ENV ?? '').update('\0', 'utf8').update(process.version).digest('hex').substring(0, 32); | ||
} | ||
@@ -181,24 +181,16 @@ function loadBabelConfig(cwd, filename, transformOptions) { | ||
async function loadBabelConfigAsync(cwd, filename, transformOptions) { | ||
const babelConfig = await (0, _loadBabelConfig.loadPartialConfigAsync)( | ||
transformOptions | ||
); | ||
const babelConfig = await (0, _loadBabelConfig.loadPartialConfigAsync)(transformOptions); | ||
assertLoadedBabelConfig(babelConfig, cwd, filename); | ||
return babelConfig; | ||
} | ||
function loadBabelOptions( | ||
cwd, | ||
filename, | ||
transformOptions, | ||
jestTransformOptions | ||
) { | ||
const {options} = loadBabelConfig(cwd, filename, transformOptions); | ||
function loadBabelOptions(cwd, filename, transformOptions, jestTransformOptions) { | ||
const { | ||
options | ||
} = loadBabelConfig(cwd, filename, transformOptions); | ||
return addIstanbulInstrumentation(options, jestTransformOptions); | ||
} | ||
async function loadBabelOptionsAsync( | ||
cwd, | ||
filename, | ||
transformOptions, | ||
jestTransformOptions | ||
) { | ||
const {options} = await loadBabelConfigAsync(cwd, filename, transformOptions); | ||
async function loadBabelOptionsAsync(cwd, filename, transformOptions, jestTransformOptions) { | ||
const { | ||
options | ||
} = await loadBabelConfigAsync(cwd, filename, transformOptions); | ||
return addIstanbulInstrumentation(options, jestTransformOptions); | ||
@@ -224,3 +216,6 @@ } | ||
function mergeBabelTransformOptions(filename, transformOptions) { | ||
const {cwd, rootDir} = transformOptions.config; | ||
const { | ||
cwd, | ||
rootDir | ||
} = transformOptions.config; | ||
// `cwd` and `root` first to allow incoming options to override it | ||
@@ -233,14 +228,6 @@ return { | ||
...options.caller, | ||
supportsDynamicImport: | ||
transformOptions.supportsDynamicImport ?? | ||
options.caller.supportsDynamicImport, | ||
supportsExportNamespaceFrom: | ||
transformOptions.supportsExportNamespaceFrom ?? | ||
options.caller.supportsExportNamespaceFrom, | ||
supportsStaticESM: | ||
transformOptions.supportsStaticESM ?? | ||
options.caller.supportsStaticESM, | ||
supportsTopLevelAwait: | ||
transformOptions.supportsTopLevelAwait ?? | ||
options.caller.supportsTopLevelAwait | ||
supportsDynamicImport: transformOptions.supportsDynamicImport ?? options.caller.supportsDynamicImport, | ||
supportsExportNamespaceFrom: transformOptions.supportsExportNamespaceFrom ?? options.caller.supportsExportNamespaceFrom, | ||
supportsStaticESM: transformOptions.supportsStaticESM ?? options.caller.supportsStaticESM, | ||
supportsTopLevelAwait: transformOptions.supportsTopLevelAwait ?? options.caller.supportsTopLevelAwait | ||
}, | ||
@@ -253,40 +240,17 @@ filename | ||
getCacheKey(sourceText, sourcePath, transformOptions) { | ||
const babelOptions = loadBabelConfig( | ||
transformOptions.config.cwd, | ||
sourcePath, | ||
mergeBabelTransformOptions(sourcePath, transformOptions) | ||
); | ||
return getCacheKeyFromConfig( | ||
sourceText, | ||
sourcePath, | ||
babelOptions, | ||
transformOptions | ||
); | ||
const babelOptions = loadBabelConfig(transformOptions.config.cwd, sourcePath, mergeBabelTransformOptions(sourcePath, transformOptions)); | ||
return getCacheKeyFromConfig(sourceText, sourcePath, babelOptions, transformOptions); | ||
}, | ||
async getCacheKeyAsync(sourceText, sourcePath, transformOptions) { | ||
const babelOptions = await loadBabelConfigAsync( | ||
transformOptions.config.cwd, | ||
sourcePath, | ||
mergeBabelTransformOptions(sourcePath, transformOptions) | ||
); | ||
return getCacheKeyFromConfig( | ||
sourceText, | ||
sourcePath, | ||
babelOptions, | ||
transformOptions | ||
); | ||
const babelOptions = await loadBabelConfigAsync(transformOptions.config.cwd, sourcePath, mergeBabelTransformOptions(sourcePath, transformOptions)); | ||
return getCacheKeyFromConfig(sourceText, sourcePath, babelOptions, transformOptions); | ||
}, | ||
process(sourceText, sourcePath, transformOptions) { | ||
const babelOptions = loadBabelOptions( | ||
transformOptions.config.cwd, | ||
sourcePath, | ||
mergeBabelTransformOptions(sourcePath, transformOptions), | ||
transformOptions | ||
); | ||
const transformResult = (0, _core().transformSync)( | ||
sourceText, | ||
babelOptions | ||
); | ||
const babelOptions = loadBabelOptions(transformOptions.config.cwd, sourcePath, mergeBabelTransformOptions(sourcePath, transformOptions), transformOptions); | ||
const transformResult = (0, _core().transformSync)(sourceText, babelOptions); | ||
if (transformResult) { | ||
const {code, map} = transformResult; | ||
const { | ||
code, | ||
map | ||
} = transformResult; | ||
if (typeof code === 'string') { | ||
@@ -304,14 +268,9 @@ return { | ||
async processAsync(sourceText, sourcePath, transformOptions) { | ||
const babelOptions = await loadBabelOptionsAsync( | ||
transformOptions.config.cwd, | ||
sourcePath, | ||
mergeBabelTransformOptions(sourcePath, transformOptions), | ||
transformOptions | ||
); | ||
const transformResult = await (0, _core().transformAsync)( | ||
sourceText, | ||
babelOptions | ||
); | ||
const babelOptions = await loadBabelOptionsAsync(transformOptions.config.cwd, sourcePath, mergeBabelTransformOptions(sourcePath, transformOptions), transformOptions); | ||
const transformResult = await (0, _core().transformAsync)(sourceText, babelOptions); | ||
if (transformResult) { | ||
const {code, map} = transformResult; | ||
const { | ||
code, | ||
map | ||
} = transformResult; | ||
if (typeof code === 'string') { | ||
@@ -336,3 +295,7 @@ return { | ||
}; | ||
var _default = transformerFactory; | ||
exports.default = _default; | ||
var _default = exports["default"] = transformerFactory; | ||
})(); | ||
module.exports = __webpack_exports__; | ||
/******/ })() | ||
; |
{ | ||
"name": "babel-jest", | ||
"description": "Jest plugin to use babel for transformation.", | ||
"version": "29.7.0", | ||
"version": "30.0.0-alpha.1", | ||
"repository": { | ||
@@ -16,2 +16,4 @@ "type": "git", | ||
"types": "./build/index.d.ts", | ||
"require": "./build/index.js", | ||
"import": "./build/index.mjs", | ||
"default": "./build/index.js" | ||
@@ -22,6 +24,6 @@ }, | ||
"dependencies": { | ||
"@jest/transform": "^29.7.0", | ||
"@jest/transform": "30.0.0-alpha.1", | ||
"@types/babel__core": "^7.1.14", | ||
"babel-plugin-istanbul": "^6.1.1", | ||
"babel-preset-jest": "^29.6.3", | ||
"babel-preset-jest": "30.0.0-alpha.1", | ||
"chalk": "^4.0.0", | ||
@@ -33,10 +35,10 @@ "graceful-fs": "^4.2.9", | ||
"@babel/core": "^7.11.6", | ||
"@jest/test-utils": "^29.7.0", | ||
"@jest/test-utils": "30.0.0-alpha.1", | ||
"@types/graceful-fs": "^4.1.3" | ||
}, | ||
"peerDependencies": { | ||
"@babel/core": "^7.8.0" | ||
"@babel/core": "^7.11.0" | ||
}, | ||
"engines": { | ||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0" | ||
"node": "^16.10.0 || ^18.12.0 || >=20.0.0" | ||
}, | ||
@@ -46,3 +48,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "4e56991693da7cd4c3730dc3579a1dd1403ee630" | ||
"gitHead": "d005cb2505c041583e0c5636d006e08666a54b63" | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
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
14482
1
302
2
1
+ Added@jest/schemas@30.0.0-alpha.1(transitive)
+ Added@jest/transform@30.0.0-alpha.1(transitive)
+ Added@jest/types@30.0.0-alpha.1(transitive)
+ Added@sinclair/typebox@0.31.28(transitive)
+ Addedbabel-plugin-jest-hoist@30.0.0-alpha.1(transitive)
+ Addedbabel-preset-jest@30.0.0-alpha.1(transitive)
+ Addedcaniuse-lite@1.0.30001616(transitive)
+ Addedci-info@4.0.0(transitive)
+ Addedelectron-to-chromium@1.4.756(transitive)
+ Addedjest-haste-map@30.0.0-alpha.1(transitive)
+ Addedjest-regex-util@30.0.0-alpha.1(transitive)
+ Addedjest-util@30.0.0-alpha.1(transitive)
+ Addedjest-worker@30.0.0-alpha.1(transitive)
+ Addedupdate-browserslist-db@1.0.15(transitive)
- Removed@jest/schemas@29.6.3(transitive)
- Removed@jest/transform@29.7.0(transitive)
- Removed@jest/types@29.6.3(transitive)
- Removed@sinclair/typebox@0.27.8(transitive)
- Removed@types/graceful-fs@4.1.9(transitive)
- Removedbabel-plugin-jest-hoist@29.6.3(transitive)
- Removedbabel-preset-jest@29.6.3(transitive)
- Removedcaniuse-lite@1.0.30001615(transitive)
- Removedci-info@3.9.0(transitive)
- Removedjest-haste-map@29.7.0(transitive)
- Removedjest-regex-util@29.6.3(transitive)
- Removedjest-util@29.7.0(transitive)
- Removedjest-worker@29.7.0(transitive)
- Removedupdate-browserslist-db@1.0.14(transitive)