Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

⚡ Million.js' compiler powered by Vite.js

Notifications You must be signed in to change notification settings

aidenybai/vite-plugin-million

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Merged into Million repository

vite-plugin-million

⚡ Million.js' compiler powered by Vite.js.

Generate raw objects instead of virtual node h calls.

Please note that this is not a full replacement of million/jsx-runtime. It only supports basic children normalization, flag resolution. It does not support the kebab, className, style, or delta helpers or JSX automatic runtime.

With vite-plugin-million: <div>Hello World</div>{ tag: 'div', props: null, children: ['Hello World'] }

Without vite-plugin-million: <div>Hello World</div>h('div', null, 'Hello World')

Install

npm install --save-dev vite-plugin-million

vite.config.ts

import { defineConfig } from 'vite';
import million from 'vite-plugin-million';

export default defineConfig({
  esbuild: {
    jsxFactory: 'h',
    jsxFragment: 'Fragment',
    jsxInject: `import { h, jsxs, Fragment } from 'million/jsx-runtime'`,
  },
  plugins: [million()],
});

tsconfig.json

{
  "compilerOptions": {
    "moduleResolution": "node",
    "jsx": "react-jsx",
    "jsxImportSource": "million"
  }
}

License

vite-plugin-million is MIT-licensed open-source software by Aiden Bai.