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
Additional allowed conditions when resolving [Conditional Exports](https://nodejs.org/api/packages.html#packages_conditional_exports) from a package.
122
123
@@ -135,7 +136,9 @@ A package with conditional exports may have the following `exports` field in its
135
136
136
137
Here, `import` and `require` are "conditions". Conditions can be nested and should be specified from most specific to least specific.
137
138
138
-
Vite has a list of "allowed conditions" and will match the first condition that is in the allowed list. The default allowed conditions are: `import`, `module`, `browser`, `default`, and `production/development` based on current mode. The `resolve.conditions` config option allows specifying additional allowed conditions.
139
+
`development|production` is a special value that is replaced with `production` or `development` depending on the value of `process.env.NODE_ENV`. It is replaced with `production` when `process.env.NODE_ENV === 'production'` and `development` otherwise.
140
+
141
+
Note that `import`, `require`, `default` conditions are always applied if the requirements are met.
139
142
140
143
:::warning Resolving subpath exports
141
144
Export keys ending with "/" is deprecated by Node and may not work well. Please contact the package author to use [`*` subpath patterns](https://nodejs.org/api/packages.html#package-entry-points) instead.
Defaults to the root [`resolve.conditions`](./shared-options.md#resolve-conditions).
40
-
41
40
These conditions are used in the plugin pipeline, and only affect non-externalized dependencies during the SSR build. Use `ssr.resolve.externalConditions` to affect externalized imports.
42
41
43
42
## ssr.resolve.externalConditions
44
43
45
44
-**Type:**`string[]`
46
-
-**Default:**`[]`
45
+
-**Default:**`['node']`
47
46
48
47
Conditions that are used during ssr import (including `ssrLoadModule`) of externalized dependencies.
Copy file name to clipboardExpand all lines: docs/guide/migration.md
+17
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,23 @@ The experimental Vite Runtime API evolved into the Module Runner API, released i
12
12
13
13
## General Changes
14
14
15
+
### Default value for `resolve.conditions`
16
+
17
+
This change does not affect users that did not configure [`resolve.conditions`](/config/shared-options#resolve-conditions) / [`ssr.resolve.conditions`](/config/ssr-options#ssr-resolve-conditions) / [`ssr.resolve.externalConditions`](/config/ssr-options#ssr-resolve-externalconditions).
18
+
19
+
In Vite 5, the default value for `resolve.conditions` was `[]` and some conditions were added internally. The default value for `ssr.resolve.conditions` was the value of `resolve.conditions`.
20
+
21
+
From Vite 6, some of the conditions are no longer added internally and need to be included in the config values.
22
+
The conditions that are no longer added internally for
23
+
24
+
-`resolve.conditions` are `['module', 'browser', 'development|production']`
25
+
-`ssr.resolve.conditions` are `['module', 'node', 'development|production']`
26
+
27
+
The default values for those options are updated to the corresponding values and `ssr.resolve.conditions` no longer uses `resolve.conditions` as the default value. Note that `development|production` is a special variable that is replaced with `production` or `development` depending on the value of `process.env.NODE_ENV`.
28
+
29
+
If you specified a custom value for `resolve.conditions` or `ssr.resolve.conditions`, you need to update it to include the new conditions.
30
+
For example, if you previously specified `['custom']` for `resolve.conditions`, you need to specify `['custom', 'module', 'browser', 'development|production']` instead.
31
+
15
32
### JSON stringify
16
33
17
34
In Vite 5, when [`json.stringify: true`](/config/shared-options#json-stringify) is set, [`json.namedExports`](/config/shared-options#json-namedexports) was disabled.
0 commit comments