You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/migration.md
+26
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,32 @@ See the [troubleshooting guide](/guide/troubleshooting.html#vite-cjs-node-api-de
34
34
35
35
## General Changes
36
36
37
+
### SSR externalized modules value now matches production
38
+
39
+
In Vite 4, SSR externalized modules are wrapped with `.default` and `.__esModule` handling for better interoperability, but it doesn't match the production behaviour when loaded by the runtime environment (e.g. Node.js), causing hard-to-catch inconsistencies. By default, all direct project dependencies are SSR externalized.
40
+
41
+
Vite 5 now removes the `.default` and `.__esModule` handling to match the production behaviour. In practice, this shouldn't affect properly-packaged dependencies, but if you encounter new issues loading modules, you can try these refactors:
42
+
43
+
```js
44
+
// Before:
45
+
import { foo } from'bar'
46
+
47
+
// After:
48
+
import_barfrom'bar'
49
+
const { foo } = _bar
50
+
```
51
+
52
+
```js
53
+
// Before:
54
+
importfoofrom'bar'
55
+
56
+
// After:
57
+
import*as_foofrom'bar'
58
+
constfoo=_foo.default
59
+
```
60
+
61
+
Note that these changes matches the Node.js behaviour, so you can also run the imports in Node.js to test it out. If you prefer to stick with the previous behaviour, you can set `legacy.proxySsrExternalModules` to `true`.
62
+
37
63
### `worker.plugins` is now a function
38
64
39
65
In Vite 4, `worker.plugins` accepted an array of plugins (`(Plugin | Plugin[])[]`). From Vite 5, it needs to be configured as a function that returns an array of plugins (`() => (Plugin | Plugin[])[]`). This change is required so parallel worker builds run more consistently and predictably.
0 commit comments