esbuild-jest
Advanced tools
Comparing version 0.3.0-beta.0 to 0.3.0-beta.1
import { transformSync } from 'esbuild'; | ||
import { extname, resolve } from 'path'; | ||
import { existsSync, readFileSync } from 'fs'; | ||
import { extname } from 'path'; | ||
const getOptions = () => { | ||
var _a; | ||
const tsconfigPath = resolve("tsconfig.json"); | ||
const tsconfig = existsSync(tsconfigPath) ? JSON.parse(readFileSync(resolve("tsconfig.json"), "utf-8")) : {compilerOptions: {target: "es2018"}}; | ||
return { | ||
format: "cjs", | ||
target: ((_a = tsconfig.compilerOptions) == null ? void 0 : _a.target) || "es2018", | ||
sourcemap: true | ||
}; | ||
}; | ||
function process(content, filename) { | ||
const options = getOptions(); | ||
const result = transformSync(content, { | ||
loader: extname(filename).slice(1), | ||
sourcefile: filename, | ||
...options | ||
sourcemap: true, | ||
format: "cjs", | ||
target: "es2018" | ||
}); | ||
return { | ||
code: result.js, | ||
code: result.code, | ||
map: { | ||
...JSON.parse(result.jsSourceMap), | ||
...JSON.parse(result.map), | ||
sourcesContent: null | ||
@@ -27,0 +17,0 @@ } |
@@ -7,25 +7,15 @@ 'use strict'; | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
const getOptions = () => { | ||
var _a; | ||
const tsconfigPath = path.resolve("tsconfig.json"); | ||
const tsconfig = fs.existsSync(tsconfigPath) ? JSON.parse(fs.readFileSync(path.resolve("tsconfig.json"), "utf-8")) : {compilerOptions: {target: "es2018"}}; | ||
return { | ||
format: "cjs", | ||
target: ((_a = tsconfig.compilerOptions) == null ? void 0 : _a.target) || "es2018", | ||
sourcemap: true | ||
}; | ||
}; | ||
function process(content, filename) { | ||
const options = getOptions(); | ||
const result = esbuild.transformSync(content, { | ||
loader: path.extname(filename).slice(1), | ||
sourcefile: filename, | ||
...options | ||
sourcemap: true, | ||
format: "cjs", | ||
target: "es2018" | ||
}); | ||
return { | ||
code: result.js, | ||
code: result.code, | ||
map: { | ||
...JSON.parse(result.jsSourceMap), | ||
...JSON.parse(result.map), | ||
sourcesContent: null | ||
@@ -32,0 +22,0 @@ } |
{ | ||
"name": "esbuild-jest", | ||
"version": "0.3.0-beta.0", | ||
"version": "0.3.0-beta.1", | ||
"description": "Jest plugin to use esbuild for transformation", | ||
@@ -5,0 +5,0 @@ "main": "esbuild-jest.js", |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
2187
45