Skip to content

Commit 43947b4

Browse files
authored
fix: compatible with CJS (unplugin#486)
1 parent 99c476e commit 43947b4

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/core/options.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { join, resolve } from 'path'
2-
import { createRequire } from 'module'
32
import { slash, toArray } from '@antfu/utils'
4-
import { isPackageExists } from 'local-pkg'
3+
import { getPackageInfoSync, isPackageExists } from 'local-pkg'
54
import type { ComponentResolver, ComponentResolverObject, Options, ResolvedOptions } from '../types'
65
import { detectTypeImports } from './type-imports/detect'
76

@@ -76,14 +75,7 @@ export function resolveOptions(options: Options, root: string): ResolvedOptions
7675
return resolved
7776
}
7877

79-
const _require = typeof require === 'undefined' ? createRequire(import.meta.url) : require
8078
function getVueVersion() {
81-
try {
82-
const vue = _require('vue')
83-
const version = vue?.default?.version || vue?.version || '3'
84-
return version.startsWith('2.') ? 'vue2' : 'vue3'
85-
}
86-
catch {
87-
return null
88-
}
79+
const version = getPackageInfoSync('vue')?.version || '3'
80+
return version.startsWith('2.') ? 'vue2' : 'vue3'
8981
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy