dai-shi/waku

Can not build with swr

hyoban opened this issue · 6 comments

hyoban commented

https://github.com/hyoban/waku-swr

When i use SWR in Client Component, it works fine in dev. But i can not build. It looks like it's always only looking for export in react-server condition.

https://swr.vercel.app/docs/with-nextjs

"default" is not exported by "node_modules/.pnpm/swr@2.2.4_react@18.3.0-canary-b30030471-20240117/node_modules/swr/core/dist/react-server.mjs", imported by "src/components/swr-demo.tsx".
file: /Users/hyoban/Developer/Demo/waku-swr/src/components/swr-demo.tsx:3:7
1: "use client";
2: 
3: import useSWR from "swr";
          ^
4: 
5: const fetcher = (url: string) => fetch(url).then((res) => res.json());
file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:337
        base = Object.assign(new Error(base.message), base);
                             ^

Error [RollupError]: "default" is not exported by "node_modules/.pnpm/swr@2.2.4_react@18.3.0-canary-b30030471-20240117/node_modules/swr/core/dist/react-server.mjs", imported by "src/components/swr-demo.tsx".
    at error (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
    at Module.error (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:12781:16)
    at Module.traceVariable (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:13218:29)
    at ModuleScope.findVariable (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:11635:39)
    at FunctionScope.findVariable (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:5935:38)
    at FunctionBodyScope.findVariable (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:5935:38)
    at Identifier.bind (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:7217:40)
    at CallExpression.bind (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:4641:23)
    at CallExpression.bind (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:8854:15)
    at VariableDeclarator.bind (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:4641:23) {
  binding: 'default',
  code: 'MISSING_EXPORT',
  exporter: '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/swr@2.2.4_react@18.3.0-canary-b30030471-20240117/node_modules/swr/core/dist/react-server.mjs',
  id: '/Users/hyoban/Developer/Demo/waku-swr/src/components/swr-demo.tsx',
  url: 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module',
  pos: 68,
  loc: {
    column: 7,
    file: '/Users/hyoban/Developer/Demo/waku-swr/src/components/swr-demo.tsx',
    line: 3
  },
  frame: '1: "use client";\n' +
    '2: \n' +
    '3: import useSWR from "swr";\n' +
    '          ^\n' +
    '4: \n' +
    '5: const fetcher = (url: string) => fetch(url).then((res) => res.json());',
  watchFiles: [
    '/Users/hyoban/Developer/Demo/waku-swr/src/entries.tsx',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/waku@0.19.1_react-dom@18.3.0-canary-b30030471-20240117_react-server-dom-webpack@18.3.0-canary_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/main.js',
    '/Users/hyoban/Developer/Demo/waku-swr/package.json',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/waku@0.19.1_react-dom@18.3.0-canary-b30030471-20240117_react-server-dom-webpack@18.3.0-canary_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/router/client.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/waku@0.19.1_react-dom@18.3.0-canary-b30030471-20240117_react-server-dom-webpack@18.3.0-canary_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/server.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/waku@0.19.1_react-dom@18.3.0-canary-b30030471-20240117_react-server-dom-webpack@18.3.0-canary_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/router/server.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/react@18.3.0-canary-b30030471-20240117/node_modules/react/react.react-server.js',
    '/Users/hyoban/Developer/Demo/waku-swr/src/templates/home-page.tsx',
    '/Users/hyoban/Developer/Demo/waku-swr/src/templates/about-page.tsx',
    '/Users/hyoban/Developer/Demo/waku-swr/src/templates/root-layout.tsx',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/react@18.3.0-canary-b30030471-20240117/node_modules/react/cjs/react.react-server.development.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/react@18.3.0-canary-b30030471-20240117/node_modules/react/cjs/react.react-server.production.min.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/react@18.3.0-canary-b30030471-20240117/node_modules/react/jsx-runtime.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/waku@0.19.1_react-dom@18.3.0-canary-b30030471-20240117_react-server-dom-webpack@18.3.0-canary_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/client.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/react@18.3.0-canary-b30030471-20240117/node_modules/react/cjs/react-jsx-runtime.production.min.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/react@18.3.0-canary-b30030471-20240117/node_modules/react/cjs/react-jsx-runtime.development.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/react-server-dom-webpack@18.3.0-canary-b30030471-20240117_react-dom@18.3.0-canary-b30030471-2_5ci7wmupwsipmnrpdqwysyyfsa/node_modules/react-server-dom-webpack/client.edge.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/react-server-dom-webpack@18.3.0-canary-b30030471-20240117_react-dom@18.3.0-canary-b30030471-2_5ci7wmupwsipmnrpdqwysyyfsa/node_modules/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/react-server-dom-webpack@18.3.0-canary-b30030471-20240117_react-dom@18.3.0-canary-b30030471-2_5ci7wmupwsipmnrpdqwysyyfsa/node_modules/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.min.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/react-dom@18.3.0-canary-b30030471-20240117_react@18.3.0-canary-b30030471-20240117/node_modules/react-dom/react-dom.react-server.js',
    '/Users/hyoban/Developer/Demo/waku-swr/src/styles.css',
    '/Users/hyoban/Developer/Demo/waku-swr/src/components/footer.tsx',
    '/Users/hyoban/Developer/Demo/waku-swr/src/components/header.tsx',
    '/Users/hyoban/Developer/Demo/waku-swr/src/components/counter.tsx',
    '/Users/hyoban/Developer/Demo/waku-swr/src/components/swr-demo.tsx',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/react-dom@18.3.0-canary-b30030471-20240117_react@18.3.0-canary-b30030471-20240117/node_modules/react-dom/cjs/react-dom.react-server.development.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/react-dom@18.3.0-canary-b30030471-20240117_react@18.3.0-canary-b30030471-20240117/node_modules/react-dom/cjs/react-dom.react-server.production.min.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/swr@2.2.4_react@18.3.0-canary-b30030471-20240117/node_modules/swr/core/dist/react-server.mjs',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/swr@2.2.4_react@18.3.0-canary-b30030471-20240117/node_modules/swr/_internal/dist/react-server.mjs',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/waku@0.19.1_react-dom@18.3.0-canary-b30030471-20240117_react-server-dom-webpack@18.3.0-canary_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/lib/renderers/utils.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/waku@0.19.1_react-dom@18.3.0-canary-b30030471-20240117_react-server-dom-webpack@18.3.0-canary_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/router/common.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/waku@0.19.1_react-dom@18.3.0-canary-b30030471-20240117_react-server-dom-webpack@18.3.0-canary_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/lib/utils/path.js'
  ]
}

Thanks for reporting. We still have some issues with library compatibility, like #90. We need more people to help.

#96 is reported before and solved at one time with a hack. But, there might be some misunderstanding.

Let's tackle it again. Hope we have a better understanding now.

Is anyone interested in digging it further?

It looks like it's always only looking for export in react-server condition.

It sounds correct for RSC. So, again, does removing --with-ssr change the situation?

hyoban commented

does removing --with-ssr change the situation?

No, The error still there

that's great to know...

Looks like a react-server conditional export is set in the client bundle

where is it??