Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not build with swr #418

Closed
Tracked by #423 ...
hyoban opened this issue Jan 23, 2024 · 6 comments · Fixed by #532
Closed
Tracked by #423 ...

Can not build with swr #418

hyoban opened this issue Jan 23, 2024 · 6 comments · Fixed by #532
Labels
help wanted Extra attention is needed

Comments

@hyoban
Copy link

hyoban commented Jan 23, 2024

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/[email protected][email protected]/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/[email protected]/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/[email protected][email protected]/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/[email protected]/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
    at Module.error (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:12781:16)
    at Module.traceVariable (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:13218:29)
    at ModuleScope.findVariable (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:11635:39)
    at FunctionScope.findVariable (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:5935:38)
    at FunctionBodyScope.findVariable (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:5935:38)
    at Identifier.bind (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:7217:40)
    at CallExpression.bind (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:4641:23)
    at CallExpression.bind (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:8854:15)
    at VariableDeclarator.bind (file:///Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected]/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/[email protected][email protected]/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/[email protected][email protected][email protected]_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/main.js',
    '/Users/hyoban/Developer/Demo/waku-swr/package.json',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected][email protected][email protected]_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/router/client.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected][email protected][email protected]_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/server.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected][email protected][email protected]_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/router/server.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected]/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/[email protected]/node_modules/react/cjs/react.react-server.development.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected]/node_modules/react/cjs/react.react-server.production.min.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected]/node_modules/react/jsx-runtime.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected][email protected][email protected]_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/client.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected]/node_modules/react/cjs/react-jsx-runtime.production.min.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected]/node_modules/react/cjs/react-jsx-runtime.development.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected][email protected]_5ci7wmupwsipmnrpdqwysyyfsa/node_modules/react-server-dom-webpack/client.edge.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected][email protected]_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/[email protected][email protected]_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/[email protected][email protected]/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/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.react-server.development.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.react-server.production.min.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected][email protected]/node_modules/swr/core/dist/react-server.mjs',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected][email protected]/node_modules/swr/_internal/dist/react-server.mjs',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected][email protected][email protected]_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/lib/renderers/utils.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected][email protected][email protected]_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/router/common.js',
    '/Users/hyoban/Developer/Demo/waku-swr/node_modules/.pnpm/[email protected][email protected][email protected]_gs5p533tfweocikxyqduoft2v4/node_modules/waku/dist/lib/utils/path.js'
  ]
}
@dai-shi
Copy link
Owner

dai-shi commented Jan 23, 2024

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?

@dai-shi dai-shi added the help wanted Extra attention is needed label Jan 23, 2024
@dai-shi
Copy link
Owner

dai-shi commented Jan 23, 2024

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
Copy link
Author

hyoban commented Jan 23, 2024

does removing --with-ssr change the situation?

No, The error still there

@dai-shi
Copy link
Owner

dai-shi commented Jan 23, 2024

that's great to know...

@himself65
Copy link
Contributor

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

@dai-shi
Copy link
Owner

dai-shi commented Jan 24, 2024

where is it??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
3 participants