Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Sep 25, 2024
1 parent 68d5be0 commit 8887eb6
Show file tree
Hide file tree
Showing 18 changed files with 355 additions and 4 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Just-in-Time Typescript and ESM support for Node.js.
- Node.js native require cache integration
- Filesystem transpile with hard disk caches
- Custom resolve aliases
- JSX support (opt-in)

## 🌟 Used by

Expand Down Expand Up @@ -211,6 +212,14 @@ Parent module's [`import.meta`](https://developer.mozilla.org/en-US/docs/Web/Jav
Try to use native require and import without jiti transformations first.
### `jsx`
- Type: Boolean | {options}
- Default: `false`
- Environment Variable: `JITI_JSX`
Enable JSX support.
## Development
- Clone this repository
Expand Down
19 changes: 19 additions & 0 deletions lib/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ export interface JitiOptions {
* Enabled if Bun is detected.
*/
tryNative?: boolean;

/**
* Enable JSX support.
*
* @experimental
*/
jsx?: boolean | JSXOptions;
}

export type ModuleCache = Record<string, NodeModule>;
Expand All @@ -163,6 +170,7 @@ export interface TransformOptions {
retainLines?: boolean;
interopDefault?: boolean;
async: boolean;
jsx?: boolean | JSXOptions;
[key: string]: any;
}

Expand All @@ -176,3 +184,14 @@ export interface JitiResolveOptions {
parentURL?: string | URL;
try?: boolean;
}

/** Reference: https://babeljs.io/docs/babel-plugin-transform-react-jsx#options */
export interface JSXOptions {
throwIfNamespace?: boolean;
runtime?: "classic" | "automatic";
importSource?: string;
pragma?: string;
pragmaFrag?: string;
useBuiltIns?: boolean;
useSpread?: boolean;
}
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"build": "pnpm clean && NODE_ENV=production pnpm webpack",
"clean": "rm -rf dist",
"dev": "pnpm clean && pnpm webpack --watch",
"jiti": "JITI_DEBUG=1 lib/jiti-cli.mjs",
"jiti": "JITI_DEBUG=1 JITI_JSX=1 lib/jiti-cli.mjs",
"lint": "eslint . && prettier -c src lib test stubs",
"lint:fix": "eslint --fix . && prettier -w src lib test stubs",
"prepack": "pnpm build",
Expand All @@ -64,7 +64,9 @@
"@babel/plugin-proposal-decorators": "^7.24.7",
"@babel/plugin-syntax-class-properties": "^7.12.13",
"@babel/plugin-syntax-import-assertions": "^7.25.6",
"@babel/plugin-syntax-jsx": "^7.24.7",
"@babel/plugin-transform-export-namespace-from": "^7.24.7",
"@babel/plugin-transform-react-jsx": "^7.25.2",
"@babel/plugin-transform-typescript": "^7.25.2",
"@babel/preset-typescript": "^7.24.7",
"@babel/template": "^7.25.0",
Expand All @@ -89,16 +91,23 @@
"estree-walker": "^3.0.3",
"fast-glob": "^3.3.2",
"mlly": "^1.7.1",
"nano-jsx": "^0.1.0",
"pathe": "^1.1.2",
"pkg-types": "^1.2.0",
"preact": "^10.24.1",
"preact-render-to-string": "^6.5.11",
"prettier": "^3.3.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"reflect-metadata": "^0.2.2",
"solid-js": "^1.9.1",
"std-env": "^3.7.0",
"terser-webpack-plugin": "^5.3.10",
"tinyexec": "^0.3.0",
"ts-loader": "^9.5.1",
"typescript": "^5.6.2",
"vitest": "^2.1.1",
"vue": "^3.5.8",
"webpack": "^5.94.0",
"webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "^5.1.4",
Expand Down
Loading

0 comments on commit 8887eb6

Please sign in to comment.