swr
swr copied to clipboard
Multiple swr version conflict
Bug report
Description / Observed Behavior
When deps use different version swr like v1 & v2. It will throw error:
![截屏2022-12-23 16 41 02](https://user-images.githubusercontent.com/5378891/209302825-4d90b62c-6777-4c3e-a57b-68422533c944.png)
It's caused by the export use package name instead of relative path and swr self package.json
not deps on swr
:
https://github.com/vercel/swr/blob/main/core/index.ts#L6
It should be:
export { SWRConfig, unstable_serialize } from './use-swr'
- export { useSWRConfig } from 'swr/_internal'
+ export { useSWRConfig } from '../_internal'
- export { mutate } from 'swr/_internal'
+ export { mutate } from '../_internal'
- export { preload } from 'swr/_internal'
+ export { preload } from '../_internal'
Or just publish @swr/internal
package and add in package.json
deps.
Expected Behavior
Not break.
Repro Steps / Code Example
https://stackblitz.com/edit/react-ts-dhpe9y?file=package.json,App.tsx
You can see the error to tell swr v2 try to find swr/_internal
with v1:
Error in turbo_modules/[email protected]/core/dist/index.js
The entrypoint for 'swr' could not successfully be resolved. The file '/turbo_modules/[email protected]/_internal' does not exist. Please log an issue with the package author or check for an updated version of the package.
Additional Context
+1