Comparing version 0.2.17 to 0.2.18
15
index.js
@@ -37,2 +37,3 @@ "use strict"; | ||
var path = __importStar(require("path")); | ||
var process = __importStar(require("process")); | ||
var vm = __importStar(require("vm")); | ||
@@ -84,3 +85,12 @@ var create_cache_key_function_1 = __importDefault(require("@jest/create-cache-key-function")); | ||
} | ||
var nodeTargetDefaults = new Map([ | ||
['12', 'es2018'], | ||
['13', 'es2019'], | ||
['14', 'es2020'], | ||
['15', 'es2021'], | ||
['16', 'es2021'], | ||
['17', 'es2022'], | ||
]); | ||
function buildSwcTransformOpts(swcOptions) { | ||
var _a; | ||
var computedSwcOptions = swcOptions || getOptionsFromSwrc(); | ||
@@ -90,2 +100,7 @@ if (!supportsEsm) { | ||
} | ||
if (!((_a = computedSwcOptions.jsc) === null || _a === void 0 ? void 0 : _a.target)) { | ||
set(computedSwcOptions, 'jsc.target', | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
nodeTargetDefaults.get(process.version.match(/v(\d+)/)[1]) || 'es2018'); | ||
} | ||
set(computedSwcOptions, 'jsc.transform.hidden.jest', true); | ||
@@ -92,0 +107,0 @@ return computedSwcOptions; |
{ | ||
"name": "@swc/jest", | ||
"version": "0.2.17", | ||
"version": "0.2.18", | ||
"description": "swc integration for jest", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -42,3 +42,3 @@ # @swc/jest | ||
**Q: Jest use CommonJS in default. But I want to use ESM.** | ||
### Q: Jest use CommonJS in default. But I want to use ESM. | ||
@@ -74,2 +74,32 @@ A: Setup Jest following this [Guide](https://jestjs.io/docs/ecmascript-modules). | ||
### Q: What ECMAScript target is set by `jsc.target`? | ||
A: By default, the version supported by your Node runtime. | ||
| Node version | Default `jsc.target` | | ||
|--------------|----------------------| | ||
| 12 | 'es2018' | | ||
| 13 | 'es2019' | | ||
| 14 | 'es2020' | | ||
| 15 | 'es2021' | | ||
| 16 | 'es2021' | | ||
| 17 | 'es2022' | | ||
You can customize this by setting an explicit version in your config: | ||
```js | ||
module.exports = { | ||
transform: { | ||
"^.+\\.(t|j)sx?$": [ | ||
"@swc/jest", | ||
{ | ||
jsc: { | ||
target: "es2021", | ||
}, | ||
}, | ||
], | ||
}, | ||
} | ||
``` | ||
## License | ||
@@ -76,0 +106,0 @@ |
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
9197
130
108