Comparing version 0.2.32 to 0.2.33
@@ -1,3 +0,3 @@ | ||
import type { Transformer } from '@jest/transform'; | ||
import { Options } from '@swc/core'; | ||
import type { Transformer } from "@jest/transform"; | ||
import { Options } from "@swc/core"; | ||
declare function createTransformer(swcTransformOpts?: Options & { | ||
@@ -4,0 +4,0 @@ experimental?: { |
65
index.js
@@ -73,3 +73,5 @@ "use strict"; | ||
insertInstrumentationOptions(jestOptions, !!canInstrument, computedSwcOptions, instrumentOptions); | ||
return (0, core_1.transformSync)(src, __assign(__assign({}, computedSwcOptions), { module: __assign(__assign({}, computedSwcOptions.module), { type: (jestOptions.supportsStaticESM ? 'es6' : 'commonjs') }), filename: filename })); | ||
return (0, core_1.transformSync)(src, __assign(__assign({}, computedSwcOptions), { module: __assign(__assign({}, computedSwcOptions.module), { type: jestOptions.supportsStaticESM | ||
? "es6" | ||
: "commonjs" }), filename: filename })); | ||
}, | ||
@@ -80,3 +82,3 @@ processAsync: function (src, filename, jestOptions) { | ||
// async transform is always ESM | ||
type: 'es6' }), filename: filename })); | ||
type: "es6" }), filename: filename })); | ||
}, | ||
@@ -90,20 +92,21 @@ getCacheKey: function (src, filename) { | ||
var baseCacheKey = cacheKeyFunction.apply(void 0, __spreadArray([src, filename], rest, false)); | ||
// @ts-expect-error - signature mismatch between Jest <27 og >=27 | ||
var options = typeof rest[0] === 'string' ? rest[1] : rest[0]; | ||
var options = typeof rest[0] === "string" ? rest[1] : rest[0]; | ||
return crypto | ||
.createHash('sha1') | ||
.createHash("sha1") | ||
.update(baseCacheKey) | ||
.update('\0', 'utf8') | ||
.update(JSON.stringify({ supportsStaticESM: options.supportsStaticESM })) | ||
.digest('hex'); | ||
} | ||
.update("\0", "utf8") | ||
.update(JSON.stringify({ | ||
supportsStaticESM: options.supportsStaticESM, | ||
})) | ||
.digest("hex"); | ||
}, | ||
}; | ||
} | ||
function getOptionsFromSwrc() { | ||
var swcrc = path.join(process.cwd(), '.swcrc'); | ||
var swcrc = path.join(process.cwd(), ".swcrc"); | ||
if (fs.existsSync(swcrc)) { | ||
var errors = []; | ||
var options = (0, jsonc_parser_1.parse)(fs.readFileSync(swcrc, 'utf-8'), errors); | ||
var options = (0, jsonc_parser_1.parse)(fs.readFileSync(swcrc, "utf-8"), errors); | ||
if (errors.length > 0) { | ||
throw new Error("Error parsing ".concat(swcrc, ": ").concat(errors.join(', '))); | ||
throw new Error("Error parsing ".concat(swcrc, ": ").concat(errors.join(", "))); | ||
} | ||
@@ -115,11 +118,11 @@ return options; | ||
var nodeTargetDefaults = new Map([ | ||
['12', 'es2018'], | ||
['13', 'es2019'], | ||
['14', 'es2020'], | ||
['15', 'es2021'], | ||
['16', 'es2021'], | ||
['17', 'es2022'], | ||
['18', 'es2022'], | ||
['19', 'es2022'], | ||
['20', 'es2022'], | ||
["12", "es2018"], | ||
["13", "es2019"], | ||
["14", "es2020"], | ||
["15", "es2021"], | ||
["16", "es2021"], | ||
["17", "es2022"], | ||
["18", "es2022"], | ||
["19", "es2022"], | ||
["20", "es2022"], | ||
// TODO: Use es2023 once @swc/core supports it | ||
@@ -137,12 +140,13 @@ // ['18', 'es2023'], | ||
if (!computedSwcOptions.env && !((_a = computedSwcOptions.jsc) === null || _a === void 0 ? void 0 : _a.target)) { | ||
set(computedSwcOptions, 'jsc.target', | ||
set(computedSwcOptions, "jsc.target", | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
nodeTargetDefaults.get(process.version.match(/v(\d+)/)[1]) || 'es2018'); | ||
nodeTargetDefaults.get(process.version.match(/v(\d+)/)[1]) || | ||
"es2018"); | ||
} | ||
set(computedSwcOptions, 'jsc.transform.hidden.jest', true); | ||
set(computedSwcOptions, "jsc.transform.hidden.jest", true); | ||
if (!computedSwcOptions.sourceMaps) { | ||
set(computedSwcOptions, 'sourceMaps', 'inline'); | ||
set(computedSwcOptions, "sourceMaps", "inline"); | ||
} | ||
if ((_b = computedSwcOptions.jsc) === null || _b === void 0 ? void 0 : _b.baseUrl) { | ||
set(computedSwcOptions, 'jsc.baseUrl', path.resolve(computedSwcOptions.jsc.baseUrl)); | ||
set(computedSwcOptions, "jsc.baseUrl", path.resolve(computedSwcOptions.jsc.baseUrl)); | ||
} | ||
@@ -157,3 +161,3 @@ return computedSwcOptions; | ||
} | ||
if ((_c = (_b = (_a = swcTransformOpts === null || swcTransformOpts === void 0 ? void 0 : swcTransformOpts.jsc) === null || _a === void 0 ? void 0 : _a.experimental) === null || _b === void 0 ? void 0 : _b.plugins) === null || _c === void 0 ? void 0 : _c.some(function (x) { return x[0] === 'swc-plugin-coverage-instrument'; })) { | ||
if ((_c = (_b = (_a = swcTransformOpts === null || swcTransformOpts === void 0 ? void 0 : swcTransformOpts.jsc) === null || _a === void 0 ? void 0 : _a.experimental) === null || _b === void 0 ? void 0 : _b.plugins) === null || _c === void 0 ? void 0 : _c.some(function (x) { return x[0] === "swc-plugin-coverage-instrument"; })) { | ||
return; | ||
@@ -170,7 +174,10 @@ } | ||
} | ||
(_d = swcTransformOpts.jsc.experimental.plugins) === null || _d === void 0 ? void 0 : _d.push(['swc-plugin-coverage-instrument', instrumentOptions !== null && instrumentOptions !== void 0 ? instrumentOptions : {}]); | ||
(_d = swcTransformOpts.jsc.experimental.plugins) === null || _d === void 0 ? void 0 : _d.push([ | ||
"swc-plugin-coverage-instrument", | ||
instrumentOptions !== null && instrumentOptions !== void 0 ? instrumentOptions : {}, | ||
]); | ||
} | ||
function set(obj, path, value) { | ||
var o = obj; | ||
var parents = path.split('.'); | ||
var parents = path.split("."); | ||
var key = parents.pop(); | ||
@@ -177,0 +184,0 @@ for (var _i = 0, parents_1 = parents; _i < parents_1.length; _i++) { |
{ | ||
"name": "@swc/jest", | ||
"version": "0.2.32", | ||
"version": "0.2.33", | ||
"description": "swc integration for jest", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"homepage": "https://github.com/swc-project/jest", | ||
"scripts": { | ||
"build": "npm run lint && tsc", | ||
"test": "npm test --workspaces", | ||
"prepublishOnly": "npm run build && node scripts/publish_helper.js prepublish", | ||
"postpublish": "node scripts/publish_helper.js postpublish", | ||
"lint": "eslint . --ext .ts && echo 'No lint errors found!'" | ||
}, | ||
"homepage": "https://github.com/swc-project/pkgs/tree/main/packages/jest", | ||
"keywords": [], | ||
@@ -24,3 +17,3 @@ "author": "강동윤 <kdy1997.dev@gmail.com>", | ||
"type": "git", | ||
"url": "https://github.com/swc-project/jest.git" | ||
"url": "https://github.com/swc-project/pkgs.git" | ||
}, | ||
@@ -32,3 +25,4 @@ "peerDependencies": { | ||
"@jest/create-cache-key-function": "^29.7.0", | ||
"jsonc-parser": "^3.2.0" | ||
"jsonc-parser": "^3.2.0", | ||
"packages": "link:.." | ||
}, | ||
@@ -51,3 +45,7 @@ "devDependencies": { | ||
"index.d.ts" | ||
] | ||
], | ||
"scripts": { | ||
"build": "tsc", | ||
"lint": "eslint . --ext .ts" | ||
} | ||
} |
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
207
13301
4
+ Addedpackages@link:..