Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kevin940726/swc-plugin-import-jsx-pragma
SWC plugin for automatically injecting an import statement for JSX pragma in classic runtime.
https://github.com/kevin940726/swc-plugin-import-jsx-pragma
jsx swc-plugin
Last synced: about 4 hours ago
JSON representation
SWC plugin for automatically injecting an import statement for JSX pragma in classic runtime.
- Host: GitHub
- URL: https://github.com/kevin940726/swc-plugin-import-jsx-pragma
- Owner: kevin940726
- License: mit
- Created: 2023-03-28T07:31:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-03-29T15:36:16.000Z (over 1 year ago)
- Last Synced: 2024-04-14T05:47:58.431Z (7 months ago)
- Topics: jsx, swc-plugin
- Language: Rust
- Homepage: https://www.npmjs.com/package/swc-plugin-import-jsx-pragma
- Size: 745 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `swc-plugin-import-jsx-pragma`
[SWC](https://swc.rs/) plugin for automatically injecting an import statement for JSX pragma in classic runtime.
## Installation
```sh
npm i -D swc-plugin-import-jsx-pragma
```## Usage
See [`jsc.experimental.plugins`](https://swc.rs/docs/configuration/compilation#jscexperimentalplugins):
```json5
// .swcrc
{
"jsc": {
"transform": {
"react": {
// Currently, these are the required configs.
"runtime": "classic",
"pragma": "createElement",
"pragmaFrag": "Fragment",
},
},
"experimental": {
"plugins": [
["swc-plugin-import-jsx-pragma", {}]
]
}
}
}
```It will take this input:
```js
export default function App() {
returnHello World
}
```And generate this output:
```js
import { createElement } from "react";
export default function App() {
return /*#__PURE__*/ createElement("h1", null, "Hello World");
}```
## Options
- `importSource`: `string`, defaults to `react`.