Skip to content

Commit

Permalink
chore: init vapor
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyuanzmj committed Jun 26, 2024
1 parent 5edc1a5 commit 8aece10
Show file tree
Hide file tree
Showing 45 changed files with 6,874 additions and 5,319 deletions.
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Vitest - Debug Current Test File",
"autoAttachChildProcesses": true,
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"args": ["run", "${relativeFile}"],
"smartStep": true,
"console": "integratedTerminal"
}
]
}
41 changes: 6 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![NPM version](https://img.shields.io/npm/v/unplugin-vue-jsx-vapor?color=a1b858&label=)](https://www.npmjs.com/package/unplugin-vue-jsx-vapor)

Convert JSX to Template for compiler-vapor.
Convert JSX to Vapor.

## Install

Expand All @@ -16,15 +16,10 @@ npm i unplugin-vue-jsx-vapor
```ts
// vite.config.ts
import VueJsxVapor from 'unplugin-vue-jsx-vapor/vite'
import { compile } from 'vue/vapor'
// or
// import { compile } from '@vue/compiler-dom'

export default defineConfig({
plugins: [
VueJsxVapor({
compile
}),
VueJsxVapor(),
],
})
```
Expand All @@ -39,15 +34,10 @@ Example: [`playground/`](./playground/)
```ts
// rollup.config.js
import VueJsxVapor from 'unplugin-vue-jsx-vapor/rollup'
import { compile } from 'vue/vapor'
// or
// import { compile } from '@vue/compiler-dom'

export default {
plugins: [
VueJsxVapor({
compile
}),
VueJsxVapor(),
],
}
```
Expand All @@ -62,11 +52,7 @@ export default {
module.exports = {
/* ... */
plugins: [
require('unplugin-vue-jsx-vapor/webpack')({
compile: require('vue/vapor')
// or
// compile: require('@vue/compiler-dom')
}),
require('unplugin-vue-jsx-vapor/webpack')(),
],
}
```
Expand All @@ -78,16 +64,10 @@ module.exports = {

```ts
// nuxt.config.js
import { compile } from 'vue/vapor'
// or
// import { compile } from '@vue/compiler-dom'
export default defineNuxtConfig({
modules: [
[
'unplugin-vue-jsx-vapor/nuxt',
{
compile
},
],
],
})
Expand All @@ -105,11 +85,7 @@ export default defineNuxtConfig({
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-vue-jsx-vapor/webpack')({
compile: require('vue/vapor')
// or
// compile: require('@vue/compiler-dom')
}),
require('unplugin-vue-jsx-vapor/webpack')(),
],
},
}
Expand All @@ -124,15 +100,10 @@ module.exports = {
// esbuild.config.js
import { build } from 'esbuild'
import VueJsxVapor from 'unplugin-vue-jsx-vapor/esbuild'
import { compile } from 'vue/vapor'
// or
// import { compile } from '@vue/compiler-dom'

build({
plugins: [
VueJsxVapor({
compile
})
VueJsxVapor()
],
})
```
Expand Down
18 changes: 5 additions & 13 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import antfu from '@antfu/eslint-config'
import { sxzz } from '@sxzz/eslint-config'

export default antfu({
export default sxzz({
ignores: ['playground'],
rules: {
'curly': 'off',
'style/object-property-newline': 'off',
'style/jsx-max-props-per-line': 'off',
'style/jsx-curly-newline': 'off',
'style/jsx-self-closing-comp': 'error',
'style/jsx-one-expression-per-line': [
'error',
{
allow: 'literal',
},
],
'unicorn/filename-case': 'off',
'import/no-default-export': 'off',
'unused-imports/no-unused-vars': 'warn',
},
})
113 changes: 58 additions & 55 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,76 +1,79 @@
{
"name": "unplugin-vue-jsx-vapor",
"type": "module",
"version": "0.1.20",
"packageManager": "[email protected]",
"description": "Convert JSX to Template for compiler-vapor",
"license": "MIT",
"homepage": "https://github.com/zhiyuanzmj/unplugin-vue-jsx-vapor#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/zhiyuanzmj/unplugin-vue-jsx-vapor.git"
},
"bugs": {
"url": "https://github.com/zhiyuanzmj/unplugin-vue-jsx-vapor/issues"
},
"description": "Convert JSX to Vapor",
"type": "module",
"keywords": [
"unplugin",
"vite",
"webpack",
"rollup",
"transform"
],
"license": "MIT",
"homepage": "https://github.com/zhiyuanzmj/unplugin-vue-jsx-vapor#readme",
"bugs": {
"url": "https://github.com/zhiyuanzmj/unplugin-vue-jsx-vapor/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/zhiyuanzmj/unplugin-vue-jsx-vapor.git"
},
"files": [
"dist"
],
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
"require": "./dist/index.cjs",
"import": "./dist/index.js"
},
"./astro": {
"types": "./dist/astro.d.ts",
"import": "./dist/astro.js",
"require": "./dist/astro.cjs"
"require": "./dist/astro.cjs",
"import": "./dist/astro.js"
},
"./rspack": {
"types": "./dist/rspack.d.ts",
"import": "./dist/rspack.js",
"require": "./dist/rspack.cjs"
"require": "./dist/rspack.cjs",
"import": "./dist/rspack.js"
},
"./vite": {
"types": "./dist/vite.d.ts",
"import": "./dist/vite.js",
"require": "./dist/vite.cjs"
"require": "./dist/vite.cjs",
"import": "./dist/vite.js"
},
"./webpack": {
"types": "./dist/webpack.d.ts",
"import": "./dist/webpack.js",
"require": "./dist/webpack.cjs"
"require": "./dist/webpack.cjs",
"import": "./dist/webpack.js"
},
"./rollup": {
"types": "./dist/rollup.d.ts",
"import": "./dist/rollup.js",
"require": "./dist/rollup.cjs"
"require": "./dist/rollup.cjs",
"import": "./dist/rollup.js"
},
"./esbuild": {
"types": "./dist/esbuild.d.ts",
"import": "./dist/esbuild.js",
"require": "./dist/esbuild.cjs"
"require": "./dist/esbuild.cjs",
"import": "./dist/esbuild.js"
},
"./nuxt": {
"types": "./dist/nuxt.d.ts",
"import": "./dist/nuxt.js",
"require": "./dist/nuxt.cjs"
"require": "./dist/nuxt.cjs",
"import": "./dist/nuxt.js"
},
"./types": {
"types": "./dist/types.d.ts",
"import": "./dist/types.js",
"require": "./dist/types.cjs"
"require": "./dist/types.cjs",
"import": "./dist/types.js"
},
"./*": "./*"
},
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"typesVersions": {
"*": {
"*": [
Expand All @@ -79,16 +82,12 @@
]
}
},
"files": [
"dist"
],
"scripts": {
"build": "tsup",
"dev": "tsup --watch src",
"build:fix": "esno scripts/postbuild.ts",
"lint": "eslint .",
"play": "npm -C playground/virtual-dom run dev",
"play:vapor": "npm -C playground/vapor run dev",
"play": "npm -C playground run dev",
"prepublishOnly": "npm run build",
"release": "bumpp && npm publish",
"start": "esno src/index.ts",
Expand Down Expand Up @@ -123,29 +122,33 @@
}
},
"dependencies": {
"@vue-macros/common": "^1.10.0",
"html-tags": "^3.3.1",
"@vue-macros/common": "^1.10.4",
"@vue-vapor/compiler-vapor": "3.2024.0-63dbc26",
"@vue-vapor/vue": "3.2024.0-63dbc26",
"html-tags": "^4.0.0",
"svg-tags": "^1.0.0",
"unplugin": "^1.5.1"
"unplugin": "^1.10.1"
},
"devDependencies": {
"@antfu/eslint-config": "^2.6.2",
"@nuxt/kit": "^3.8.2",
"@nuxt/schema": "^3.8.2",
"@types/node": "^20.10.3",
"@antfu/eslint-config": "^2.21.1",
"@babel/types": "^7.24.7",
"@nuxt/kit": "^3.12.2",
"@nuxt/schema": "^3.12.2",
"@sxzz/eslint-config": "^3.13.0",
"@types/node": "^20.14.9",
"@types/svg-tags": "^1.0.2",
"bumpp": "^9.2.0",
"bumpp": "^9.4.1",
"chalk": "^5.3.0",
"eslint": "^8.55.0",
"esno": "^4.0.0",
"eslint": "^9.5.0",
"esno": "^4.7.0",
"fast-glob": "^3.3.2",
"nodemon": "^3.0.2",
"rimraf": "^5.0.5",
"rollup": "^4.6.1",
"tsup": "^8.0.1",
"typescript": "^5.3.2",
"vite": "^4.5.1",
"vitest": "^0.34.6",
"webpack": "^5.89.0"
"nodemon": "^3.1.4",
"rimraf": "^5.0.7",
"rollup": "^4.18.0",
"tsup": "^8.1.0",
"typescript": "^5.5.2",
"vite": "^5.3.1",
"vitest": "^1.6.0",
"webpack": "^5.92.1"
}
}
20 changes: 20 additions & 0 deletions playground/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<script lang="tsx">
import { defineComponent, ref } from 'vue'
export default defineComponent({
setup() {
const count = ref(0)
setInterval(() => {
count.value++
}, 1000)
const Count = () => <div>{count.value * 2}</div>
return (
<>
<Count />
</>
)
},
})
</script>
1 change: 1 addition & 0 deletions playground/Count.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<template>Count</template>
File renamed without changes.
14 changes: 14 additions & 0 deletions playground/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { createVaporApp } from 'vue/vapor'

const modules = import.meta.glob<any>('./**/*.(vue|js)')
const mod = (modules[`.${location.pathname}`] || modules['./App.vue'])()

mod.then(({ default: mod }) => {
const app = createVaporApp(mod)
app.mount('#app')

// @ts-expect-error
globalThis.unmount = () => {
app.unmount()
}
})
19 changes: 19 additions & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "nodemon -w '../../src/**/*.ts' -e .ts -x vite --port 5174"
},
"dependencies": {
"@vue-macros/define-render": "^1.5.5",
"vite-plugin-vue-devtools": "^7.3.4",
"vue": "npm:@vue-vapor/[email protected]"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.5",
"@vue-macros/volar": "^0.23.0",
"unplugin-vue-jsx-vapor": "workspace:*",
"vite": "^5.3.1",
"vite-plugin-inspect": "^0.8.4"
}
}
File renamed without changes.
Loading

0 comments on commit 8aece10

Please sign in to comment.