esbuild-jest
Advanced tools
Comparing version 0.2.2 to 0.3.0-beta.0
@@ -1,5 +0,6 @@ | ||
declare const _default: { | ||
process(content: string, filename: string): {}; | ||
declare function process(content: string, filename: string): { | ||
code: string; | ||
map: any; | ||
}; | ||
export default _default; | ||
export { process }; |
@@ -1,36 +0,31 @@ | ||
import { resolve } from 'path'; | ||
import { buildSync } from 'esbuild'; | ||
import { builtinModules } from 'module'; | ||
import { transformSync } from 'esbuild'; | ||
import { extname, resolve } from 'path'; | ||
import { existsSync, readFileSync } from 'fs'; | ||
var _a, _b, _c; | ||
const pkg = require(resolve("package.json")); | ||
const external = [ | ||
...builtinModules, | ||
...Object.keys((_a = pkg.dependencies) != null ? _a : {}), | ||
...Object.keys((_b = pkg.devDependencies) != null ? _b : {}), | ||
...Object.keys((_c = pkg.peerDependencies) != null ? _c : {}) | ||
]; | ||
const build = (filename) => { | ||
const {outputFiles} = buildSync({ | ||
entryPoints: [filename], | ||
outdir: "./dist", | ||
minify: false, | ||
bundle: true, | ||
write: false, | ||
target: "es2018", | ||
sourcemap: true, | ||
external | ||
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 | ||
}); | ||
return outputFiles.reduce((cur, item) => { | ||
const key = item.path.includes(".map") ? "map" : "code"; | ||
cur[key] = Buffer.from(item.contents).toString(); | ||
return cur; | ||
}, {}); | ||
}; | ||
var index = { | ||
process(content, filename) { | ||
return build(filename); | ||
} | ||
}; | ||
return { | ||
code: result.js, | ||
map: { | ||
...JSON.parse(result.jsSourceMap), | ||
sourcesContent: null | ||
} | ||
}; | ||
} | ||
export default index; | ||
export { process }; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var esbuild = require('esbuild'); | ||
var path = require('path'); | ||
var esbuild = require('esbuild'); | ||
var module$1 = require('module'); | ||
var fs = require('fs'); | ||
var _a, _b, _c; | ||
const pkg = require(path.resolve("package.json")); | ||
const external = [ | ||
...module$1.builtinModules, | ||
...Object.keys((_a = pkg.dependencies) != null ? _a : {}), | ||
...Object.keys((_b = pkg.devDependencies) != null ? _b : {}), | ||
...Object.keys((_c = pkg.peerDependencies) != null ? _c : {}) | ||
]; | ||
const build = (filename) => { | ||
const {outputFiles} = esbuild.buildSync({ | ||
entryPoints: [filename], | ||
outdir: "./dist", | ||
minify: false, | ||
bundle: true, | ||
write: false, | ||
target: "es2018", | ||
sourcemap: true, | ||
external | ||
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 | ||
}); | ||
return outputFiles.reduce((cur, item) => { | ||
const key = item.path.includes(".map") ? "map" : "code"; | ||
cur[key] = Buffer.from(item.contents).toString(); | ||
return cur; | ||
}, {}); | ||
}; | ||
var index = { | ||
process(content, filename) { | ||
return build(filename); | ||
} | ||
}; | ||
return { | ||
code: result.js, | ||
map: { | ||
...JSON.parse(result.jsSourceMap), | ||
sourcesContent: null | ||
} | ||
}; | ||
} | ||
module.exports = index; | ||
exports.process = process; |
{ | ||
"name": "esbuild-jest", | ||
"version": "0.2.2", | ||
"version": "0.3.0-beta.0", | ||
"description": "Jest plugin to use esbuild for transformation", | ||
@@ -23,5 +23,5 @@ "main": "esbuild-jest.js", | ||
"homepage": "https://github.com/aelbore/esbuild-jest#readme", | ||
"dependencies": { | ||
"esbuild": "^0.6.16" | ||
"peerDependencies": { | ||
"esbuild": ">=0.7.8" | ||
} | ||
} |
@@ -11,3 +11,3 @@ # esbuild-jest | ||
```bash | ||
npm install --save-dev esbuild-jest | ||
npm install --save-dev esbuild-jest esbuild | ||
``` | ||
@@ -14,0 +14,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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
2
3025
65
+ Added@esbuild/aix-ppc64@0.24.0(transitive)
+ Added@esbuild/android-arm@0.24.0(transitive)
+ Added@esbuild/android-arm64@0.24.0(transitive)
+ Added@esbuild/android-x64@0.24.0(transitive)
+ Added@esbuild/darwin-arm64@0.24.0(transitive)
+ Added@esbuild/darwin-x64@0.24.0(transitive)
+ Added@esbuild/freebsd-arm64@0.24.0(transitive)
+ Added@esbuild/freebsd-x64@0.24.0(transitive)
+ Added@esbuild/linux-arm@0.24.0(transitive)
+ Added@esbuild/linux-arm64@0.24.0(transitive)
+ Added@esbuild/linux-ia32@0.24.0(transitive)
+ Added@esbuild/linux-loong64@0.24.0(transitive)
+ Added@esbuild/linux-mips64el@0.24.0(transitive)
+ Added@esbuild/linux-ppc64@0.24.0(transitive)
+ Added@esbuild/linux-riscv64@0.24.0(transitive)
+ Added@esbuild/linux-s390x@0.24.0(transitive)
+ Added@esbuild/linux-x64@0.24.0(transitive)
+ Added@esbuild/netbsd-x64@0.24.0(transitive)
+ Added@esbuild/openbsd-arm64@0.24.0(transitive)
+ Added@esbuild/openbsd-x64@0.24.0(transitive)
+ Added@esbuild/sunos-x64@0.24.0(transitive)
+ Added@esbuild/win32-arm64@0.24.0(transitive)
+ Added@esbuild/win32-ia32@0.24.0(transitive)
+ Added@esbuild/win32-x64@0.24.0(transitive)
+ Addedesbuild@0.24.0(transitive)
- Removedesbuild@^0.6.16
- Removedesbuild@0.6.34(transitive)