New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

import-jsx

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

import-jsx - npm Package Compare versions

Comparing version 3.1.0 to 4.0.0

cache.js

39

index.js
'use strict';
const path = require('path');
const destructuringTransform = require('@babel/plugin-transform-destructuring');
const restSpreadTransform = require('@babel/plugin-proposal-object-rest-spread');
const jsxTransform = require('@babel/plugin-transform-react-jsx');
const resolveFrom = require('resolve-from');
const callerPath = require('caller-path');
const babel = require('@babel/core');
const cache = require('./cache');
const {version} = require('./package.json');

@@ -16,9 +13,8 @@ const importJsx = (moduleId, options) => {

options = Object.assign({
options = {
pragma: 'h',
pragmaFrag: 'Fragment',
cache: true,
// Put on options object for easier testing.
supportsDestructuring: Number(process.versions.node.split('.')[0]) >= 6
}, options);
...options
};

@@ -42,23 +38,11 @@ const modulePath = resolveFrom(path.dirname(callerPath()), moduleId);

module._compile = source => {
if (source.includes('React')) {
options.pragma = 'React.createElement';
options.pragmaFrag = 'React.Fragment';
}
const plugins = [
[restSpreadTransform, {useBuiltIns: true}],
options.supportsDestructuring ? null : destructuringTransform,
[jsxTransform, {pragma: options.pragma, pragmaFrag: options.pragmaFrag, useBuiltIns: true}]
].filter(Boolean);
const result = babel.transformSync(source, {
plugins,
filename: modulePath,
sourceMaps: 'inline',
babelrc: false,
configFile: false
const result = cache({
modulePath,
options,
source,
version
});
module._compile = oldCompile;
module._compile(result.code, modulePath);
module._compile(result, modulePath);
};

@@ -81,2 +65,3 @@

module.exports = importJsx;
module.exports.default = importJsx;

@@ -83,0 +68,0 @@ module.exports.create = options => {

{
"name": "import-jsx",
"version": "3.1.0",
"version": "4.0.0",
"description": "Require and transpile JSX on the fly",

@@ -13,9 +13,11 @@ "license": "MIT",

"engines": {
"node": ">= 4"
"node": ">=10"
},
"scripts": {
"test": "xo && nyc --check-coverage --branches=100 --lines=100 --functions=100 --statements=100 ava"
"test": "xo && ava"
},
"files": [
"index.js"
"index.js",
"cache.js",
"transform.js"
],

@@ -35,9 +37,27 @@ "keywords": [

"caller-path": "^2.0.0",
"resolve-from": "^3.0.0"
"find-cache-dir": "^3.2.0",
"make-dir": "^3.0.2",
"resolve-from": "^3.0.0",
"rimraf": "^3.0.0"
},
"devDependencies": {
"ava": "^0.19.1",
"nyc": "^13.3.0",
"xo": "^0.18.2"
"prettier": "^2.0.2",
"xo": "^0.28.1"
},
"prettier": {
"tabs": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid"
},
"xo": {
"ignore": [
"test/fixtures"
],
"rules": {
"node/no-deprecated-api": "off"
}
}
}

@@ -1,2 +0,2 @@

# import-jsx [![Build Status](https://travis-ci.org/vadimdemedes/import-jsx.svg?branch=master)](https://travis-ci.org/vadimdemedes/import-jsx)
# import-jsx ![Build Status](https://github.com/vadimdemedes/import-jsx/workflows/test/badge.svg)

@@ -10,3 +10,2 @@ > Require and transpile JSX on the fly

## Install

@@ -18,3 +17,2 @@

## Usage

@@ -30,3 +28,3 @@

**react.js**
**React**

@@ -36,6 +34,6 @@ ```jsx

module.exports = <div/>;
module.exports = <div />;
```
**preact.js**
**Preact**

@@ -45,6 +43,6 @@ ```jsx

module.exports = <div/>;
module.exports = <div />;
```
**custom.js**
**Any JSX pragma**

@@ -54,3 +52,3 @@ ```jsx

module.exports = <div/>;
module.exports = <div />;
```

@@ -89,3 +87,3 @@

Enable or disable caching of transpiled sources.
Cache transpiled source code.

@@ -116,5 +114,1 @@ ### importJsx.create([options])

```
## License
MIT © [Vadim Demedes](https://github.com/vadimdemedes)
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