@@ -9,12 +9,14 @@ import isCore from 'is-core-module'
9
9
import type { Plugin , ResolvedConfig } from 'vite'
10
10
import { createFilter } from '@rollup/pluginutils'
11
11
import c from 'picocolors'
12
- import { name , version } from '../package.json'
13
12
import { aliasMatches , transformWithEsbuild } from './compiler'
14
13
import { viteDefine } from './define'
15
14
import type { MockServerPluginOptions , ServerBuildOption } from './types'
16
15
import { ensureProxies , lookupFile , normalizePath } from './utils'
17
16
17
+ declare const __PACKAGE_NAME__ : string
18
+ declare const __PACKAGE_VERSION__ : string
19
+
18
20
type PluginContext < T = Plugin [ 'buildEnd' ] > = T extends (
19
21
this : infer R ,
20
22
...args : any [ ]
@@ -107,7 +109,7 @@ export async function generateMockServer(
107
109
108
110
function getMockDependencies ( deps : Metafile [ 'inputs' ] , alias : ResolvedConfig [ 'resolve' ] [ 'alias' ] ) : string [ ] {
109
111
const list = new Set < string > ( )
110
- const excludeDeps = [ name , 'connect' , 'cors' ]
112
+ const excludeDeps = [ __PACKAGE_NAME__ , 'connect' , 'cors' ]
111
113
const isAlias = ( p : string ) => alias . find ( ( { find } ) => aliasMatches ( find , p ) )
112
114
Object . keys ( deps ) . forEach ( ( mPath ) => {
113
115
const imports = deps [ mPath ] . imports
@@ -132,7 +134,7 @@ function generatePackageJson(pkg: any, mockDeps: string[]) {
132
134
} ,
133
135
dependencies : {
134
136
'connect' : '^3.7.0' ,
135
- 'vite-plugin-mock-dev-server' : `^${ version } ` ,
137
+ 'vite-plugin-mock-dev-server' : `^${ __PACKAGE_VERSION__ } ` ,
136
138
'cors' : '^2.8.5' ,
137
139
} as Record < string , string > ,
138
140
pnpm : { peerDependencyRules : { ignoreMissing : [ 'vite' ] } } ,
0 commit comments