Skip to content

Commit 72c4b85

Browse files
committed
chore: move isUsingRemix and isUsingNext to env
1 parent ed37b05 commit 72c4b85

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

src/configs/react.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { isPackageExists } from 'local-pkg'
22
import { ensurePackages, interopDefault, toArray } from '../shared'
33
import { GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX } from '../constants/glob'
4+
import { isUsingNext, isUsingRemix } from '../env'
45
import type {
56
OptionsFiles,
67
OptionsOverrides,
@@ -10,13 +11,6 @@ import type {
1011

1112
// react refresh
1213
const ReactRefreshAllowConstantExportPackages = ['vite']
13-
const RemixPackages = [
14-
'@remix-run/node',
15-
'@remix-run/react',
16-
'@remix-run/serve',
17-
'@remix-run/dev',
18-
]
19-
const NextJsPackages = ['next']
2014

2115
export async function react(
2216
options: OptionsTypeScriptWithTypes & OptionsOverrides & OptionsFiles = {},
@@ -45,8 +39,6 @@ export async function react(
4539
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
4640
i => isPackageExists(i),
4741
)
48-
const isUsingRemix = RemixPackages.some(i => isPackageExists(i))
49-
const isUsingNext = NextJsPackages.some(i => isPackageExists(i))
5042

5143
const plugins = pluginReact.configs.all.plugins
5244

src/env.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,29 @@ export const isInEditor = !!(
99
&& !process.env.CI
1010
)
1111
export const hasTypeScript = isPackageExists('typescript')
12-
// export const hasReact = isPackageExists('react') || isPackageExists('next')
13-
export const hasVue
14-
= isPackageExists('vue')
15-
|| isPackageExists('nuxt')
16-
|| isPackageExists('vitepress')
17-
|| isPackageExists('@slidev/cli')
18-
export const hasUnocss
19-
= isPackageExists('unocss')
20-
|| isPackageExists('@unocss/webpack')
21-
|| isPackageExists('@unocss/nuxt')
22-
export const hasTailwindCSS = isPackageExists('tailwindcss') && !hasUnocss
12+
13+
const VueJsPackages = [
14+
'vue',
15+
'nuxt',
16+
'vitepress',
17+
'@slidev/cli',
18+
]
19+
20+
export const hasVue = hasPackages(VueJsPackages)
21+
22+
const RemixPackages = [
23+
'@remix-run/node',
24+
'@remix-run/react',
25+
'@remix-run/serve',
26+
'@remix-run/dev',
27+
]
28+
29+
const NextJsPackages = ['next']
30+
31+
// export const hasReact = hasPackages(['react', ...RemixPackages, ...NextJsPackages])
32+
export const isUsingRemix = hasPackages(RemixPackages)
33+
export const isUsingNext = hasPackages(NextJsPackages)
34+
35+
function hasPackages(packages: string[]) {
36+
return packages.some(name => isPackageExists(name))
37+
}

0 commit comments

Comments
 (0)