create-lve 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/config.js CHANGED
@@ -94,13 +94,17 @@ const vitePlusDeps = (isUno) => ({
94
94
  },
95
95
  })
96
96
 
97
+ const reactDeps = (isUno) => ({
98
+ devDependencies: isUno ? { unocss: 'latest' } : undefined,
99
+ })
100
+
97
101
  const FRAMEWORK_CONFIG = {
98
102
  next: {
99
103
  deps: (isUno) => ({
100
104
  devDependencies: isUno ? { unocss: 'latest' } : { tailwindcss: 'latest' },
101
105
  }),
102
106
  },
103
- react: { deps: vitePlusDeps },
107
+ react: { deps: reactDeps },
104
108
  vue: { deps: vitePlusDeps },
105
109
  }
106
110
 
package/index.js CHANGED
@@ -111,20 +111,20 @@ async function main() {
111
111
  templateDir: path.resolve(__dirname, `template-${project.framework}`),
112
112
  isNext: project.framework === 'next',
113
113
  isUno: project.cssEngine === 'unocss',
114
- pkgManager: project.framework === 'next' ? 'pnpm' : 'vp',
115
- devCmd: project.framework === 'next' ? 'pnpm dev' : 'vp dev',
116
- fmtCmd: project.framework === 'next' ? 'pnpm fmt' : 'vp fmt',
114
+ pkgManager: project.framework === 'next' ? 'pnpm' : project.framework === 'vue' ? 'vp' : 'pnpm',
115
+ devCmd: project.framework === 'next' ? 'pnpm dev' : project.framework === 'vue' ? 'vp dev' : 'pnpm dev',
116
+ fmtCmd: project.framework === 'next' ? 'pnpm fmt' : project.framework === 'vue' ? 'vp fmt' : 'pnpm fmt',
117
117
  }
118
118
 
119
119
  const s = p.spinner()
120
120
 
121
- if (!ctx.isNext) {
121
+ if (project.framework === 'vue') {
122
122
  try {
123
123
  execSync('vp --version', { stdio: 'ignore' })
124
124
  } catch {
125
125
  p.log.error(pc.red('未检测到 VitePlus (vp) 环境'))
126
126
  p.note(
127
- pc.white(`React/Vue 模板依赖 vp 工具链:\n${pc.cyan('https://viteplus.dev/guide')}`),
127
+ pc.white(`Vue 模板依赖 vp 工具链:\n${pc.cyan('https://viteplus.dev/guide')}`),
128
128
  '环境缺失',
129
129
  )
130
130
  process.exit(1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-lve",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "bin": {
5
5
  "create-lve": "index.js"
6
6
  },
@@ -0,0 +1,7 @@
1
+ {
2
+ "semi": false,
3
+ "singleQuote": true,
4
+ "trailingComma": "all",
5
+ "sortImports": true,
6
+ "sortTailwindcss": true
7
+ }
@@ -1 +1,2 @@
1
- vp staged
1
+ npx oxlint --fix
2
+ npx oxfmt
@@ -1,3 +1,3 @@
1
1
  {
2
- "recommendations": ["VoidZero.vite-plus-extension-pack"]
2
+ "recommendations": ["oxc.oxc-vscode"]
3
3
  }
@@ -0,0 +1,8 @@
1
+ {
2
+ "rules": {
3
+ "typescript/no-unused-vars": "error",
4
+ "typescript/no-explicit-any": "warn",
5
+ "react/rules-of-hooks": "error",
6
+ "react/exhaustive-deps": "warn"
7
+ }
8
+ }
@@ -4,10 +4,13 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
- "dev": "vp dev",
8
- "build": "tsc -b && vp build",
9
- "preview": "vp preview",
10
- "prepare": "vp config"
7
+ "dev": "vite",
8
+ "build": "tsc -b && vite build",
9
+ "preview": "vite preview",
10
+ "lint": "oxlint",
11
+ "lint:fix": "oxlint --fix",
12
+ "fmt": "oxfmt",
13
+ "fmt:check": "oxfmt --check"
11
14
  },
12
15
  "dependencies": {
13
16
  "@tanstack/react-query": "latest",
@@ -18,18 +21,19 @@
18
21
  "zustand": "latest"
19
22
  },
20
23
  "devDependencies": {
21
- "@babel/core": "latest",
22
24
  "@tailwindcss/vite": "latest",
23
- "@types/babel__core": "latest",
24
25
  "@types/node": "latest",
25
26
  "@types/react": "latest",
26
27
  "@types/react-dom": "latest",
27
28
  "@vitejs/plugin-react": "latest",
28
- "babel-plugin-react-compiler": "latest",
29
29
  "oxc-transform": "latest",
30
+ "oxfmt": "latest",
31
+ "oxlint": "latest",
30
32
  "tailwindcss": "latest",
31
33
  "typescript": "latest",
32
- "vite": "latest",
33
- "vite-plus": "latest"
34
+ "vite": "latest"
35
+ },
36
+ "lint-staged": {
37
+ "*": "oxfmt --no-error-on-unmatched-pattern"
34
38
  }
35
39
  }
@@ -1,48 +1,32 @@
1
- import { defineConfig, loadEnv, lazyPlugins } from 'vite-plus'
1
+ import { defineConfig, loadEnv, type Plugin } from 'vite'
2
2
  import react from '@vitejs/plugin-react'
3
3
 
4
4
  const mode = process.env.NODE_ENV || 'development'
5
5
  const env = loadEnv(mode, process.cwd(), '')
6
- // React Compiler: true = OXC (Rust native, experimental), false = Babel (official, stable)
7
- const USE_OXC = true
6
+
7
+ // OXC Rust native, experimental
8
+ function oxcReactCompiler(): Plugin {
9
+ return {
10
+ name: 'oxc-react-compiler',
11
+ enforce: 'pre',
12
+ async transform(code, id) {
13
+ if (!/\.[tj]sx$/.test(id)) return
14
+ const { transform } = await import('oxc-transform')
15
+ const result = await transform(id, code, {
16
+ jsx: { runtime: 'automatic' },
17
+ reactCompiler: { target: '19' },
18
+ })
19
+ return { code: result.code, map: result.map }
20
+ },
21
+ }
22
+ }
8
23
 
9
24
  // https://vite.dev/config/
10
25
  export default defineConfig({
11
- fmt: { semi: false, singleQuote: true },
12
- staged: {
13
- '*': 'vp check --fix',
14
- },
15
- lint: { options: { typeAware: true, typeCheck: true } },
16
26
  plugins: [
17
27
  /* VITE_PLUS_PLUGINS */
28
+ oxcReactCompiler(),
18
29
  react(),
19
- lazyPlugins(async () => {
20
- if (USE_OXC) {
21
- const { transform } = await import('oxc-transform')
22
- return [
23
- {
24
- name: 'oxc-react-compiler',
25
- enforce: 'pre',
26
- transform(code, id) {
27
- if (!/\.[tj]sx$/.test(id)) return
28
- const result = transform(id, code, {
29
- jsx: { runtime: 'automatic' },
30
- reactCompiler: { target: '19' },
31
- })
32
- return { code: result.code, map: result.map }
33
- },
34
- },
35
- ]
36
- } else {
37
- const { reactCompilerPreset } = await import('@vitejs/plugin-react')
38
- const { default: babel } = await import('@rolldown/plugin-babel')
39
- return [
40
- babel({
41
- presets: [reactCompilerPreset()],
42
- }),
43
- ]
44
- }
45
- }),
46
30
  ],
47
31
  resolve: {
48
32
  tsconfigPaths: true,
@@ -52,7 +36,12 @@ export default defineConfig({
52
36
  output: {
53
37
  manualChunks(id) {
54
38
  if (!id.includes('node_modules')) return
55
- const pkg = id.match(/node_modules\/(?:@[^/]+\/)?([^/]+)/)?.[1]
39
+ // pnpm: node_modules/.pnpm/pkg@ver/node_modules/real-pkg/...
40
+ // npm: node_modules/real-pkg/...
41
+ const match = id.match(
42
+ /node_modules\/(?:\.pnpm\/[^/]+\/node_modules\/)?(@[^/]+\/[^/]+|[^/]+)/,
43
+ )
44
+ const pkg = match?.[1]
56
45
  if (pkg === 'react') return 'vendor-react'
57
46
  if (pkg === 'react-dom') return 'vendor-react-dom'
58
47
  if (pkg === 'react-router') return 'vendor-router'