esbuild-jest
Advanced tools
Comparing version 0.5.0-beta.1 to 0.5.0-beta.2
import path, { extname } from 'path'; | ||
import { transformSync } from 'esbuild'; | ||
import babelJest from 'babel-jest'; | ||
const { process } = babelJest.createTransformer({ | ||
plugins: [ | ||
"@babel/plugin-transform-modules-commonjs" | ||
], | ||
parserOpts: { | ||
plugins: [ | ||
"jsx", | ||
"typescript" | ||
] | ||
} | ||
}); | ||
function babelTransform(opts) { | ||
const { sourceText , sourcePath , config , options } = opts; | ||
const babelResult = process(sourceText, sourcePath, config, options); | ||
return babelResult.code; | ||
} | ||
const loaders = [ | ||
@@ -54,6 +36,7 @@ "js", | ||
/// https://github.com/threepointone/esjest-transform/blob/main/src/index.js | ||
/// this will supoort the jest.mock | ||
/// this will support the jest.mock | ||
/// https://github.com/aelbore/esbuild-jest/issues/12 | ||
/// TODO: transform the jest.mock to a function using babel traverse/parse then hoist it | ||
if (sources.code.indexOf("ock(") >= 0 || (opts === null || opts === void 0 ? void 0 : opts.instrument)) { | ||
const source = babelTransform({ | ||
const source = require('./transformer').babelTransform({ | ||
sourceText: content, | ||
@@ -60,0 +43,0 @@ sourcePath: filename, |
@@ -5,3 +5,2 @@ 'use strict'; | ||
var esbuild = require('esbuild'); | ||
var babelJest = require('babel-jest'); | ||
@@ -11,21 +10,3 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var path__default = /*#__PURE__*/_interopDefaultLegacy(path); | ||
var babelJest__default = /*#__PURE__*/_interopDefaultLegacy(babelJest); | ||
const { process } = babelJest__default['default'].createTransformer({ | ||
plugins: [ | ||
"@babel/plugin-transform-modules-commonjs" | ||
], | ||
parserOpts: { | ||
plugins: [ | ||
"jsx", | ||
"typescript" | ||
] | ||
} | ||
}); | ||
function babelTransform(opts) { | ||
const { sourceText , sourcePath , config , options } = opts; | ||
const babelResult = process(sourceText, sourcePath, config, options); | ||
return babelResult.code; | ||
} | ||
const loaders = [ | ||
@@ -63,6 +44,7 @@ "js", | ||
/// https://github.com/threepointone/esjest-transform/blob/main/src/index.js | ||
/// this will supoort the jest.mock | ||
/// this will support the jest.mock | ||
/// https://github.com/aelbore/esbuild-jest/issues/12 | ||
/// TODO: transform the jest.mock to a function using babel traverse/parse then hoist it | ||
if (sources.code.indexOf("ock(") >= 0 || (opts === null || opts === void 0 ? void 0 : opts.instrument)) { | ||
const source = babelTransform({ | ||
const source = require('./transformer').babelTransform({ | ||
sourceText: content, | ||
@@ -69,0 +51,0 @@ sourcePath: filename, |
{ | ||
"name": "esbuild-jest", | ||
"version": "0.5.0-beta.1", | ||
"version": "0.5.0-beta.2", | ||
"description": "Jest plugin to use esbuild for transformation", | ||
@@ -30,3 +30,8 @@ "main": "esbuild-jest.js", | ||
"babel-jest": "^26.6.3" | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"@babel/preset-typescript" | ||
] | ||
} | ||
} |
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
10532
6
206