Skip to content

Commit 50cac1d

Browse files
authored
sections on browser and preserveModules
1 parent 4c4876d commit 50cac1d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,34 @@
4747
//...
4848
```
4949
50+
## Problematic Settings
51+
52+
> **Warning** <br />
53+
> Use at your own discretion
54+
55+
### dont use `browser` field
56+
57+
webpack's resolve module algorithm picks a more specific field from `package.json` (and other bundlers too), so webpack chooses UMD module from `browser` field on the default and that breaks tree-shaking[^1]
58+
59+
[^1]: Source: https://github.com/TanStack/query/discussions/3986 - danke https://github.com/jeetiss
60+
61+
62+
<details>
63+
<summary>@tanstack/query-example-react-nextjs</summary>
64+
65+
<img width="1506" alt="Снимок экрана 2022-08-05 в 11 12 48" src="https://user-images.githubusercontent.com/6726016/183033639-20b33c71-5c81-442c-a711-baa3b266f0dc.png">
66+
67+
</details>
68+
69+
70+
### dont use `preserveModules`
71+
72+
CJS build contains `preserveModules` enabled and that creates bundle problems
73+
- all external modules are copied to the `dist` folder and shipped to `npm`, so all users download them twice
74+
75+
- Useing a browser field and `preserveModules` don't copy files specified by this field, so it creates issues like https://github.com/TanStack/query/issues/3965
76+
77+
5078
## `load-esm.{ts,mts}`
5179
5280
```typescript

0 commit comments

Comments
 (0)