Closed himself65 closed 8 months ago
same kind of code run success in storybook and next.js
BTW, SWR 2.1.5 works
I think because they update the exports
https://unpkg.com/browse/swr@2.2.0/package.json
"react-server": "./core/dist/react-server.mjs",
Yeah, it's because this new condition is added in exports
.
Hmm, wait, your file is under "use client". So, we should simply ignore it on server bundling?
Does it work with waku dev
?
waku dev works, but not for build
diff --git a/src/lib/builder.ts b/src/lib/builder.ts
index 4c87114..a9cfe11 100644
--- a/src/lib/builder.ts
+++ b/src/lib/builder.ts
@@ -62,7 +62,7 @@ const analyzeEntries = async (entriesFile: string) => {
ssr: {
noExternal: /^(?!node:)/,
// FIXME this is very adhoc.
- external: ["react", "minimatch"],
+ external: ["react", "minimatch", "swr"],
},
resolve: {
conditions: ["react-server"],
That ☝️ seems to work around the build error.
This is slightly related with #79, but we don't have a good workaround for this. I think we might need to revisit how to use Vite for server bundling.
It seems can't use in server components.
Hi, thanks for jumping in. Can anyone try #103 to see how it change the error?
The latest version v0.14.0
causes another error:
import { serialize, OBJECT, SWRConfig as SWRConfig$1, defaultConfig, withArgs, SWRGlobalState, createCacheHelper, isUndefined, getTimestamp, UNDEFINED, isFunction, revalidateEvents, internalMutate, useIsomorphicLayoutEffect, subscribeCallback, IS_SERVER, rAF, IS_REACT_LEGACY, mergeObjects } from 'swr/_internal';
^^^^^^^^^^^^^^^
SyntaxError: The requested module 'swr/_internal' does not provide an export named 'IS_REACT_LEGACY'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)
Can anyone investigate it??
Not sure if it is somehow related with #111.
Upstream: https://github.com/vercel/swr/issues/2700
repo: https://github.com/himself65/affine-waku/blob/issue-swr/src/Counter.tsx