Skip to content

Commit 0629357

Browse files
authored
fix: get vue version in esm version (unplugin#481)
1 parent 8032758 commit 0629357

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/core/options.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { join, resolve } from 'path'
2+
import { createRequire } from 'module'
23
import { slash, toArray } from '@antfu/utils'
34
import { isPackageExists } from 'local-pkg'
45
import type { ComponentResolver, ComponentResolverObject, Options, ResolvedOptions } from '../types'
@@ -75,10 +76,10 @@ export function resolveOptions(options: Options, root: string): ResolvedOptions
7576
return resolved
7677
}
7778

79+
const _require = createRequire(import.meta.url)
7880
function getVueVersion() {
7981
try {
80-
// eslint-disable-next-line @typescript-eslint/no-var-requires
81-
const vue = require('vue')
82+
const vue = _require('vue')
8283
const version = vue?.default?.version || vue?.version || '3'
8384
return version.startsWith('2.') ? 'vue2' : 'vue3'
8485
}

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