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
feat: log warning if svelte field causes difference in resolve (#510)
* feat: log deprecation warning if svelte field causes difference in resolve
* perf: only compare svelte resolve with vite resolve on first occurrence
* fix: add vite resolve error to log
* docs: add faq entry for svelte field deprecation
* fix: add FAQ entry and link to it from logs, refactor logging code a bit
* fix: log resolve difference
* refactor: log reduced warning at buildEnd, log details during debug only. add flag to disable warning log.
* docs: update wording and improve exports map example
* Apply suggestions from code review
Co-authored-by: Ben McCann <[email protected]>
* docs: use more neutral language for resolve differences, svelte field isn't deprecated yet
* Apply suggestions from code review
Co-authored-by: Ben McCann <[email protected]>
* docs: remove glob exports from example, add note about deep exports
* docs: spelling
Co-authored-by: Ben McCann <[email protected]>
* chore: fix changeset to use minor
---------
Co-authored-by: Ben McCann <[email protected]>
Copy file name to clipboardExpand all lines: docs/faq.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -208,3 +208,34 @@ module.exports = {
208
208
+ }
209
209
}
210
210
```
211
+
212
+
<!-- the following header generates an anchor that is used in logging, do not modify!-->
213
+
214
+
### conflicts in svelte resolve
215
+
216
+
| If you see a warning logged for this when using a Svelte library, please tell the library maintainers.
217
+
218
+
In the past, Svelte recommended using the custom `svelte` field in `package.json` to allow libraries to point at `.svelte` source files.
219
+
This field requires a custom implementation to resolve, so you have to use a bundler plugin and this plugin needs to implement resolving.
220
+
Since then, Node has added support for [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), which have more generic support in bundlers and Node itself. So to increase the compatibility with the wider ecosystem and reduce the implementation needs for current and future bundler plugins, it is recommended that packages use the `svelte` exports condition.
221
+
222
+
Example:
223
+
224
+
```diff
225
+
// package.json
226
+
"files": ["dist"],
227
+
"svelte": "dist/index.js",
228
+
+ "exports": {
229
+
+ ".": {
230
+
+ "svelte": "./dist/index.js"
231
+
+ }
232
+
}
233
+
```
234
+
235
+
You can also add individual exports of .svelte files in the exports map which gives users a choice to also use deep imports.
236
+
See the faq about [vite and prebundling](#what-is-going-on-with-vite-and-pre-bundling-dependencies) why they can be useful at times.
237
+
238
+
> Library authors are highly encouraged to update their packages to add the new exports condition as outlined above. Check out
239
+
> [svelte-package](https://kit.svelte.dev/docs/packaging) which already supports it.
240
+
>
241
+
> For backwards compatibility, you can keep the `svelte` field in addition to the `exports` condition. But make sure that both always resolve to the same files.
`WARNING: The following packages use a svelte resolve configuration in package.json that has conflicting results and is going to cause problems future.\n\n${[
271
+
...packagesWithResolveWarnings
272
+
].join('\n')}\n\nPlease see ${FAQ_LINK_CONFLICTS_IN_SVELTE_RESOLVE} for details.`
0 commit comments