Skip to content

Commit 7347de4

Browse files
committed
fix(vite-plugin-uni): 兼容 pinia v3+ 版本 无法直接访问 dist
1 parent a1a9bd7 commit 7347de4

File tree

1 file changed

+9
-1
lines changed
  • packages/vite-plugin-uni/src/configResolved/plugins

1 file changed

+9
-1
lines changed

packages/vite-plugin-uni/src/configResolved/plugins/resolveId.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
import path from 'path'
22
// import debug from 'debug'
3+
import fs from 'fs-extra'
34
import type { Plugin } from 'vite'
45
import { resolveBuiltIn, resolveUTSModule } from '@dcloudio/uni-cli-shared'
56

67
import type { VitePluginUniResolvedOptions } from '../..'
78

89
// const debugResolve = debug('uni:resolve-id')
910

11+
const isPiniaVersion3 =
12+
Number(
13+
fs
14+
.readJSONSync(resolveBuiltIn(path.join('pinia/package.json')))
15+
.version.split('.')[0]
16+
) >= 3
17+
1018
const BUILT_IN_MODULES = {
1119
'vue-router': 'dist/vue-router.esm-bundler.js',
1220
vuex: 'dist/vuex.esm-bundler.js',
@@ -17,7 +25,7 @@ const BUILT_IN_MODULES = {
1725
'@dcloudio/uni-shared': 'dist/uni-shared.es.js',
1826
'@dcloudio/uni-stacktracey': 'dist/uni-stacktracey.es.js',
1927
'@vue/shared': 'dist/shared.esm-bundler.js',
20-
pinia: 'dist/pinia.mjs',
28+
pinia: isPiniaVersion3 ? '' : 'dist/pinia.mjs',
2129
}
2230

2331
export type BuiltInModulesKey = keyof typeof BUILT_IN_MODULES

0 commit comments

Comments
 (0)