create-lve 0.4.32 → 0.5.2
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/index.js +1 -1
- package/package.json +1 -1
- package/template-react/.oxfmtrc.json +7 -0
- package/template-react/.vite-hooks/pre-commit +2 -1
- package/template-react/.vscode/extensions.json +1 -1
- package/template-react/oxlint.json +8 -0
- package/template-react/package.json +14 -10
- package/template-react/vite.config.ts +27 -18
package/index.js
CHANGED
|
@@ -55,7 +55,7 @@ async function main() {
|
|
|
55
55
|
shouldOverwrite = await p.confirm({ message: `目录已存在,是否清空?`, initialValue: false })
|
|
56
56
|
if (p.isCancel(shouldOverwrite)) onCancel()
|
|
57
57
|
}
|
|
58
|
-
project = { path: name, framework: '
|
|
58
|
+
project = { path: name, framework: 'react', cssEngine: 'tailwind', shouldOverwrite }
|
|
59
59
|
} else {
|
|
60
60
|
// 交互模式
|
|
61
61
|
project = await p.group(
|
package/package.json
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
npx oxlint --fix
|
|
2
|
+
npx oxfmt
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "
|
|
8
|
-
"build": "tsc -b &&
|
|
9
|
-
"preview": "
|
|
10
|
-
"
|
|
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
|
-
"@rolldown/plugin-babel": "latest",
|
|
23
24
|
"@tailwindcss/vite": "latest",
|
|
24
|
-
"@types/babel__core": "latest",
|
|
25
25
|
"@types/node": "latest",
|
|
26
26
|
"@types/react": "latest",
|
|
27
27
|
"@types/react-dom": "latest",
|
|
28
28
|
"@vitejs/plugin-react": "latest",
|
|
29
|
-
"
|
|
29
|
+
"oxc-transform": "latest",
|
|
30
|
+
"oxfmt": "latest",
|
|
31
|
+
"oxlint": "latest",
|
|
30
32
|
"tailwindcss": "latest",
|
|
31
33
|
"typescript": "latest",
|
|
32
|
-
"vite": "latest"
|
|
33
|
-
|
|
34
|
+
"vite": "latest"
|
|
35
|
+
},
|
|
36
|
+
"lint-staged": {
|
|
37
|
+
"*": "oxfmt --no-error-on-unmatched-pattern"
|
|
34
38
|
}
|
|
35
39
|
}
|
|
@@ -1,27 +1,32 @@
|
|
|
1
|
-
import { defineConfig, loadEnv,
|
|
2
|
-
import react
|
|
1
|
+
import { defineConfig, loadEnv, type Plugin } from 'vite'
|
|
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
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
|
+
}
|
|
23
|
+
|
|
7
24
|
// https://vite.dev/config/
|
|
8
25
|
export default defineConfig({
|
|
9
|
-
fmt: { semi: false, singleQuote: true },
|
|
10
|
-
staged: {
|
|
11
|
-
'*': 'vp check --fix',
|
|
12
|
-
},
|
|
13
|
-
lint: { options: { typeAware: true, typeCheck: true } },
|
|
14
26
|
plugins: [
|
|
15
27
|
/* VITE_PLUS_PLUGINS */
|
|
28
|
+
oxcReactCompiler(),
|
|
16
29
|
react(),
|
|
17
|
-
lazyPlugins(async () => {
|
|
18
|
-
const { default: babel } = await import('@rolldown/plugin-babel')
|
|
19
|
-
return [
|
|
20
|
-
babel({
|
|
21
|
-
presets: [reactCompilerPreset()],
|
|
22
|
-
}),
|
|
23
|
-
]
|
|
24
|
-
}),
|
|
25
30
|
],
|
|
26
31
|
resolve: {
|
|
27
32
|
tsconfigPaths: true,
|
|
@@ -31,11 +36,15 @@ export default defineConfig({
|
|
|
31
36
|
output: {
|
|
32
37
|
manualChunks(id) {
|
|
33
38
|
if (!id.includes('node_modules')) return
|
|
34
|
-
|
|
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]
|
|
35
45
|
if (pkg === 'react') return 'vendor-react'
|
|
36
46
|
if (pkg === 'react-dom') return 'vendor-react-dom'
|
|
37
|
-
if (pkg === 'react-router'
|
|
38
|
-
return 'vendor-router'
|
|
47
|
+
if (pkg === 'react-router') return 'vendor-router'
|
|
39
48
|
if (id.includes('@tanstack')) return 'vendor-query'
|
|
40
49
|
if (pkg === 'zustand') return 'vendor-state'
|
|
41
50
|
if (pkg === 'jotai') return 'vendor-atom'
|