Skip to content

Commit

Permalink
refactor: use pnpm monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyuanzmj committed Dec 24, 2024
1 parent 4b0f335 commit 530251b
Show file tree
Hide file tree
Showing 67 changed files with 1,711 additions and 969 deletions.
4 changes: 0 additions & 4 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": [
"@changesets/changelog-github",
{ "repo": "zhiyuanzmj/unplugin-vue-jsx-vapor" }
],
"commit": false,
"fixed": [],
"linked": [],
Expand Down
5 changes: 0 additions & 5 deletions .changeset/green-beers-hang.md

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 zhiyuanzmj <https://github.com/zhiyuanzmj>
Copyright (c) 2023 zhiyuanzmj <https://github.com/zhiyuanzmj>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
143 changes: 14 additions & 129 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"name": "unplugin-vue-jsx-vapor",
"version": "1.0.9",
"packageManager": "[email protected]",
"packageManager": "[email protected]",
"description": "Convert Vue JSX to Vapor",
"type": "module",
"keywords": [
Expand All @@ -12,155 +10,42 @@
"transform"
],
"license": "MIT",
"homepage": "https://github.com/zhiyuanzmj/unplugin-vue-jsx-vapor#readme",
"homepage": "https://github.com/unplugin/unplugin-vue-jsx-vapor#readme",
"bugs": {
"url": "https://github.com/zhiyuanzmj/unplugin-vue-jsx-vapor/issues"
"url": "https://github.com/unplugin/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",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
},
"./astro": {
"types": "./dist/astro.d.ts",
"require": "./dist/astro.cjs",
"import": "./dist/astro.js"
},
"./rspack": {
"types": "./dist/rspack.d.ts",
"require": "./dist/rspack.cjs",
"import": "./dist/rspack.js"
},
"./vite": {
"types": "./dist/vite.d.ts",
"require": "./dist/vite.cjs",
"import": "./dist/vite.js"
},
"./webpack": {
"types": "./dist/webpack.d.ts",
"require": "./dist/webpack.cjs",
"import": "./dist/webpack.js"
},
"./rollup": {
"types": "./dist/rollup.d.ts",
"require": "./dist/rollup.cjs",
"import": "./dist/rollup.js"
},
"./esbuild": {
"types": "./dist/esbuild.d.ts",
"require": "./dist/esbuild.cjs",
"import": "./dist/esbuild.js"
},
"./nuxt": {
"types": "./dist/nuxt.d.ts",
"require": "./dist/nuxt.cjs",
"import": "./dist/nuxt.js"
},
"./types": {
"types": "./dist/types.d.ts",
"require": "./dist/types.cjs",
"import": "./dist/types.js"
},
"./compiler": {
"types": "./dist/core/compiler/index.d.ts",
"require": "./dist/core/compiler/index.cjs",
"import": "./dist/core/compiler/index.js"
},
"./*": "./*"
},
"typesVersions": {
"*": {
"*": [
"./dist/*",
"./*"
]
}
"url": "git+https://github.com/unplugin/unplugin-vue-jsx-vapor.git"
},
"scripts": {
"build": "tsup",
"dev": "tsup --watch src",
"build:fix": "esno scripts/postbuild.ts",
"typecheck": "tsc --noEmit",
"dev": "pnpm run --filter=\"./packages/*\" --parallel dev",
"build": "pnpm run --filter=\"./packages/*\" build",
"typecheck": "pnpm run --filter=\"./packages/*\" --parallel typecheck",
"publish": "pnpm build && changeset publish",
"lint": "eslint .",
"play": "npm -C playground run dev",
"release": "bumpp && npm publish",
"publish": "pnpm build && changeset publish",
"start": "esno src/index.ts",
"test": "vitest"
},
"peerDependencies": {
"@nuxt/kit": "^3",
"@nuxt/schema": "^3",
"esbuild": "*",
"rollup": "^3",
"vite": ">=3",
"webpack": "^4 || ^5"
},
"peerDependenciesMeta": {
"@nuxt/kit": {
"optional": true
},
"@nuxt/schema": {
"optional": true
},
"esbuild": {
"optional": true
},
"rollup": {
"optional": true
},
"vite": {
"optional": true
},
"webpack": {
"optional": true
}
},
"dependencies": {
"@babel/parser": "^7.24.7",
"@babel/types": "^7.24.7",
"@vue-macros/common": "^1.10.4",
"@vue/compiler-core": "https://pkg.pr.new/vuejs/core-vapor/@vue/compiler-core@2eae25e",
"@vue/compiler-dom": "https://pkg.pr.new/vuejs/core-vapor/@vue/compiler-dom@2eae25e",
"@vue/compiler-vapor": "https://pkg.pr.new/vuejs/core-vapor/@vue/compiler-vapor@2eae25e",
"@vue/runtime-vapor": "https://pkg.pr.new/vuejs/core-vapor/@vue/runtime-vapor@2eae25e",
"@vue/shared": "https://pkg.pr.new/vuejs/core-vapor/@vue/shared@2eae25e",
"magic-string-stack": "^0.1.1",
"source-map-js": "^1.2.0",
"unplugin": "^1.11.0",
"vue": "https://pkg.pr.new/vuejs/core-vapor/vue@2eae25e"
},
"devDependencies": {
"@antfu/eslint-config": "^2.21.2",
"@babel/parser": "^7.24.7",
"@babel/types": "^7.24.7",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.7",
"@nuxt/kit": "^3.12.3",
"@nuxt/schema": "^3.12.3",
"@sxzz/eslint-config": "^3.13.0",
"@types/node": "^20.14.9",
"bumpp": "^9.4.1",
"chalk": "^5.3.0",
"conventional-changelog-cli": "^5.0.0",
"eslint": "^9.6.0",
"esno": "^4.7.0",
"fast-glob": "^3.3.2",
"nodemon": "^3.1.4",
"rimraf": "^5.0.7",
"rollup": "^4.18.0",
"tsup": "^8.1.0",
"typescript": "^5.5.3",
"vite": "^5.3.2",
"vitest": "^1.6.0",
"webpack": "^5.92.1"
"typescript": "^5.7.0",
"unplugin": "^1.11.0",
"vitest": "^1.6.0"
}
}
7 changes: 7 additions & 0 deletions packages/compiler/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @vue-jsx-vapor/compiler

## 0.0.1

### Patch Changes

- fe259ed: refactor: use pnpm monorepo
68 changes: 68 additions & 0 deletions packages/compiler/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"name": "@vue-jsx-vapor/compiler",
"version": "0.0.1",
"packageManager": "[email protected]",
"description": "Vue JSX Vapor Compiler",
"type": "module",
"keywords": [
"vue",
"jsx",
"vapor",
"compiler"
],
"license": "MIT",
"homepage": "https://github.com/unplugin/unplugin-vue-jsx-vapor#readme",
"bugs": {
"url": "https://github.com/unplugin/unplugin-vue-jsx-vapor/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/unplugin/unplugin-vue-jsx-vapor.git"
},
"files": [
"dist"
],
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"dev": "./src/index.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
},
"./*": "./*"
},
"typesVersions": {
"*": {
"*": [
"./dist/*",
"./*"
]
}
},
"publishConfig": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.js"
},
"./*": "./*"
},
"scripts": {
"build": "tsup",
"dev": "DEV=true tsup",
"typecheck": "tsc --noEmit",
"release": "bumpp && npm publish",
"test": "vitest"
},
"dependencies": {
"@babel/parser": "^7.24.7",
"@babel/types": "^7.24.7",
"@vue-macros/common": "^1.10.4",
"@vue/compiler-core": "catalog:",
"@vue/compiler-dom": "catalog:",
"@vue/compiler-vapor": "catalog:",
"@vue/runtime-vapor": "catalog:",
"@vue/shared": "catalog:"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
DynamicFlag,
type IRDynamicInfo,
IRNodeTypes,
type IRNodeTypes,
} from '@vue/compiler-vapor'
import { createSimpleExpression } from '@vue/compiler-dom'
import {
Expand All @@ -16,7 +16,7 @@ import {
jsxOpeningFragment,
parenthesizedExpression,
} from '@babel/types'
import { isJSXElement } from '../../utils'
import { isJSXElement } from '../utils'
import type { TransformContext } from '../transform'
import type { BlockIRNode } from '../ir/index'

Expand All @@ -29,7 +29,7 @@ export function newDynamic(): IRDynamicInfo {

export function newBlock(node: BlockIRNode['node']): BlockIRNode {
return {
type: IRNodeTypes.BLOCK,
type: 1 satisfies IRNodeTypes.BLOCK,
node,
dynamic: newDynamic(),
effect: [],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
62 changes: 62 additions & 0 deletions src/core/compiler/utils.ts → packages/compiler/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@ import type { VaporDirectiveNode } from './ir'
import type {
BigIntLiteral,
CallExpression,
ConditionalExpression,
Expression,
JSXAttribute,
JSXElement,
JSXFragment,
LogicalExpression,
Node,
NumericLiteral,
SourceLocation,
StringLiteral,
} from '@babel/types'

import type { MagicString } from '@vue-macros/common'

const __BROWSER__ = false

export function propToExpression(prop: AttributeNode | VaporDirectiveNode) {
Expand Down Expand Up @@ -291,3 +296,60 @@ export function getReturnExpression(node: Node): Expression | undefined {
}
}
}

export function addAttribute(node: Node, str: string, s: MagicString) {
const end =
node.type === 'JSXElement'
? node.openingElement.name.end!
: node.type === 'JSXFragment'
? node.openingFragment.end! - 1
: null
if (end) s.appendRight(end, str)
}

export function overwrite(
start: number | undefined,
end: number | undefined,
content: string,
s: MagicString,
method:
| 'prependLeft'
| 'prependRight'
| 'appendLeft'
| 'appendRight' = 'prependLeft',
) {
if (start === end) {
s[method](start!, content)
} else {
s.overwrite(start!, end!, content)
}
}

export function isJSXExpression(node?: Node | null): boolean {
return (
!!node &&
(isJSXElement(node) ||
isConditionalExpression(node) ||
isLogicalExpression(node) ||
isMapCallExpression(node))
)
}

export function isJSXElement(
node?: Node | null,
): node is JSXElement | JSXFragment {
return !!node && (node.type === 'JSXElement' || node.type === 'JSXFragment')
}

export function isConditionalExpression(
node: Node,
): node is ConditionalExpression {
return (
node.type === 'ConditionalExpression' &&
(isJSXExpression(node.consequent) || isJSXExpression(node.alternate))
)
}

export function isLogicalExpression(node: Node): node is LogicalExpression {
return node.type === 'LogicalExpression' && isJSXExpression(node.right)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, test } from 'vitest'
import { BindingTypes } from '@vue/compiler-dom'
import { type CompilerOptions, compile as _compile } from '../src/core/compiler'
import { type CompilerOptions, compile as _compile } from '../src'

export function compile(template: string, options: CompilerOptions = {}) {
return _compile(template, {
Expand Down
Loading

0 comments on commit 530251b

Please sign in to comment.