vite 2.5.5 → 2.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of vite might be problematic. Click here for more details.
- package/CHANGELOG.md +46 -0
- package/dist/node/chunks/{dep-07ec9cdd.js → dep-05fcddd5.js} +258 -222
- package/dist/node/chunks/dep-05fcddd5.js.map +1 -0
- package/dist/node/chunks/{dep-a247570d.js → dep-499befab.js} +2 -2
- package/dist/node/chunks/{dep-a247570d.js.map → dep-499befab.js.map} +1 -1
- package/dist/node/chunks/{dep-8a1f5a00.js → dep-58243dfd.js} +2 -2
- package/dist/node/chunks/{dep-8a1f5a00.js.map → dep-58243dfd.js.map} +1 -1
- package/dist/node/chunks/{dep-ebe44577.js → dep-fcb82982.js} +2 -2
- package/dist/node/chunks/{dep-ebe44577.js.map → dep-fcb82982.js.map} +1 -1
- package/dist/node/cli.js +4 -4
- package/dist/node/index.d.ts +13 -8
- package/dist/node/index.js +2 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
- package/src/node/__tests__/build.spec.ts +39 -4
- package/src/node/__tests__/packages/name/package.json +3 -0
- package/src/node/__tests__/packages/noname/package.json +1 -0
- package/src/node/build.ts +15 -10
- package/src/node/config.ts +9 -1
- package/src/node/index.ts +2 -0
- package/src/node/optimizer/esbuildDepPlugin.ts +3 -2
- package/src/node/plugin.ts +2 -2
- package/src/node/plugins/esbuild.ts +51 -33
- package/src/node/plugins/importAnalysis.ts +6 -4
- package/src/node/plugins/importAnalysisBuild.ts +1 -1
- package/src/node/server/index.ts +5 -21
- package/src/node/server/middlewares/spaFallback.ts +32 -0
- package/src/node/server/pluginContainer.ts +0 -13
- package/src/node/server/transformRequest.ts +1 -0
- package/src/node/ssr/__tests__/ssrTransform.spec.ts +22 -22
- package/src/node/ssr/ssrExternal.ts +10 -4
- package/src/node/ssr/ssrTransform.ts +6 -1
- package/.DS_Store +0 -0
- package/dist/node/chunks/dep-07ec9cdd.js.map +0 -1
- package/src/node/.DS_Store +0 -0
- package/yarn-error.log +0 -8027
|
@@ -149,43 +149,43 @@ test('import.meta', async () => {
|
|
|
149
149
|
})
|
|
150
150
|
|
|
151
151
|
test('dynamic import', async () => {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
152
|
+
const result = await ssrTransform(
|
|
153
|
+
`export const i = () => import('./foo')`,
|
|
154
|
+
null,
|
|
155
|
+
null
|
|
156
|
+
)
|
|
157
|
+
expect(result.code).toMatchInlineSnapshot(`
|
|
156
158
|
"const i = () => __vite_ssr_dynamic_import__('./foo')
|
|
157
159
|
Object.defineProperty(__vite_ssr_exports__, \\"i\\", { enumerable: true, configurable: true, get(){ return i }});"
|
|
158
160
|
`)
|
|
161
|
+
expect(result.deps).toEqual([])
|
|
162
|
+
expect(result.dynamicDeps).toEqual(['./foo'])
|
|
159
163
|
})
|
|
160
164
|
|
|
161
165
|
test('do not rewrite method definition', async () => {
|
|
162
|
-
|
|
163
|
-
(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
)
|
|
169
|
-
).code
|
|
170
|
-
).toMatchInlineSnapshot(`
|
|
166
|
+
const result = await ssrTransform(
|
|
167
|
+
`import { fn } from 'vue';class A { fn() { fn() } }`,
|
|
168
|
+
null,
|
|
169
|
+
null
|
|
170
|
+
)
|
|
171
|
+
expect(result.code).toMatchInlineSnapshot(`
|
|
171
172
|
"const __vite_ssr_import_0__ = await __vite_ssr_import__(\\"vue\\");
|
|
172
173
|
class A { fn() { __vite_ssr_import_0__.fn() } }"
|
|
173
174
|
`)
|
|
175
|
+
expect(result.deps).toEqual(['vue'])
|
|
174
176
|
})
|
|
175
177
|
|
|
176
178
|
test('do not rewrite catch clause', async () => {
|
|
177
|
-
|
|
178
|
-
(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
)
|
|
184
|
-
).code
|
|
185
|
-
).toMatchInlineSnapshot(`
|
|
179
|
+
const result = await ssrTransform(
|
|
180
|
+
`import {error} from './dependency';try {} catch(error) {}`,
|
|
181
|
+
null,
|
|
182
|
+
null
|
|
183
|
+
)
|
|
184
|
+
expect(result.code).toMatchInlineSnapshot(`
|
|
186
185
|
"const __vite_ssr_import_0__ = await __vite_ssr_import__(\\"./dependency\\");
|
|
187
186
|
try {} catch(error) {}"
|
|
188
187
|
`)
|
|
188
|
+
expect(result.deps).toEqual(['./dependency'])
|
|
189
189
|
})
|
|
190
190
|
|
|
191
191
|
// #2221
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
2
|
import path from 'path'
|
|
3
3
|
import { tryNodeResolve, InternalResolveOptions } from '../plugins/resolve'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
createDebugger,
|
|
6
|
+
isDefined,
|
|
7
|
+
lookupFile,
|
|
8
|
+
resolveFrom,
|
|
9
|
+
unique
|
|
10
|
+
} from '../utils'
|
|
5
11
|
import { ResolvedConfig } from '..'
|
|
6
12
|
import { createFilter } from '@rollup/pluginutils'
|
|
7
13
|
|
|
14
|
+
const debug = createDebugger('vite:ssr-external')
|
|
15
|
+
|
|
8
16
|
/**
|
|
9
17
|
* Heuristics for determining whether a dependency should be externalized for
|
|
10
18
|
* server-side rendering.
|
|
@@ -63,9 +71,7 @@ export function resolveSSRExternal(
|
|
|
63
71
|
requireEntry = require.resolve(id, { paths: [root] })
|
|
64
72
|
} catch (e) {
|
|
65
73
|
// resolve failed, assume include
|
|
66
|
-
|
|
67
|
-
`Bundling package for SSR due to resolve failure. ${e.message}`
|
|
68
|
-
)
|
|
74
|
+
debug(`Failed to resolve entries for package "${id}"\n`, e)
|
|
69
75
|
continue
|
|
70
76
|
}
|
|
71
77
|
if (!entry) {
|
|
@@ -39,6 +39,7 @@ export async function ssrTransform(
|
|
|
39
39
|
|
|
40
40
|
let uid = 0
|
|
41
41
|
const deps = new Set<string>()
|
|
42
|
+
const dynamicDeps = new Set<string>()
|
|
42
43
|
const idToImportMap = new Map<string, string>()
|
|
43
44
|
const declaredConst = new Set<string>()
|
|
44
45
|
|
|
@@ -200,6 +201,9 @@ export async function ssrTransform(
|
|
|
200
201
|
},
|
|
201
202
|
onDynamicImport(node) {
|
|
202
203
|
s.overwrite(node.start, node.start + 6, ssrDynamicImportKey)
|
|
204
|
+
if (node.type === 'ImportExpression' && node.source.type === 'Literal') {
|
|
205
|
+
dynamicDeps.add(node.source.value as string)
|
|
206
|
+
}
|
|
203
207
|
}
|
|
204
208
|
})
|
|
205
209
|
|
|
@@ -221,7 +225,8 @@ export async function ssrTransform(
|
|
|
221
225
|
return {
|
|
222
226
|
code: s.toString(),
|
|
223
227
|
map,
|
|
224
|
-
deps: [...deps]
|
|
228
|
+
deps: [...deps],
|
|
229
|
+
dynamicDeps: [...dynamicDeps]
|
|
225
230
|
}
|
|
226
231
|
}
|
|
227
232
|
|
package/.DS_Store
DELETED
|
Binary file
|