Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@emotion/babel-plugin-jsx-pragmatic
Advanced tools
Insert code to load a module corresponding to JSX pragma.
This package is a fork of babel-plugin-jsx-pragmatic to support React Fragments.
The original README of babel-plugin-jsx-pragmatic with some modifications is shown below.
@babel/plugin-transform-react-jsx has a pragma
option that's used when transforming JSX to function calls instead of the default function React.createElement
.
This Babel plugin is a companion to that feature that allows you to dynamically load a module associated with the pragma
value.
Example:
Given this file:
<Some jsx="element" />
babel would normally transform the JSX to:
React.createElement(Some, { jsx: 'element' })
By setting the pragma
option like this:
babel.transformSync(code, {
plugins: [
[
'@babel/plugin-transform-react-jsx',
{
pragma: 'whatever'
}
]
]
})
It would instead transform it to:
whatever(Some, { jsx: 'element' })
However, you might need to load a module corresponding to whatever
in each module containing JSX:
import whatever from 'whatever'
// or
var whatever = require('whatever')
This plugin allows you to make that part dynamic as well:
babel.transformSync(code, {
plugins: [
[
'@babel/plugin-transform-react-jsx',
{
pragma: 'whatever'
}
],
[
'@emotion/babel-plugin-jsx-pragmatic',
{
module: '/something/whatever',
import: 'whatever'
}
]
]
})
Results in:
import { default as whatever } from '/something/whatever'
module
String. Module ID or pathname. The value of the ModuleSpecifier
of an import. Required.
import
String. The identifier that you want to import the module
with. This should correspond to the root identifier of the pragma
value. Required. Examples:
{
plugins: [
[
'@babel/plugin-transform-react-jsx',
{
pragma: 'x'
}
],
[
'@emotion/babel-plugin-jsx-pragmatic',
{
module: '/something/whatever',
import: 'x'
}
]
]
}
{
plugins: [
[
'@babel/plugin-transform-react-jsx',
{
pragma: 'x.y'
}
],
[
'@emotion/babel-plugin-jsx-pragmatic',
{
module: '/something/whatever',
import: 'x'
}
]
]
}
export
String. The export that you want to import as import
from module
. Default value is default
(the default export). Examples:
// Will import the default export (`default`)
{
module: "whatever",
import: "x"
}
// import {default as x} from "whatever"
// Will import the default export (`default`)
{
module: "whatever",
import: "x",
export: "default",
}
// import {default as x} from "whatever"
// Will import the export named `something`
{
module: "whatever",
import: "x",
export: "something",
}
// import {something as x} from "whatever"
Doesn't do anything special in the case that the file being transformed
already imports or declares an identifier with the same name as import
.
Doesn't take into account when a file actually contains a JSX pragma comment.
FAQs
Insert code to load a module corresponding to JSX pragma.
The npm package @emotion/babel-plugin-jsx-pragmatic receives a total of 192,804 weekly downloads. As such, @emotion/babel-plugin-jsx-pragmatic popularity was classified as popular.
We found that @emotion/babel-plugin-jsx-pragmatic demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.