Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

esbuild-jest

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-jest - npm Package Compare versions

Comparing version 0.5.0-beta.1 to 0.5.0-beta.2

transformer.js

23

esbuild-jest.es.js
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"
]
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc