Skip to content

build error in SWR 2.2.0 #96

@himself65

Description

@himself65
"use client";

import { useState } from "react";
import useSWR from 'swr'

export const Counter = () => {
  // @ts-ignore
  const { data } = useSWR('hello', () => 'world', {
    suspense: true
  })
  const [count, setCount] = useState(0);
  return (
    <div style={{ border: "3px blue dashed", margin: "1em", padding: "1em" }}>
      <p>Count: {count}</p>
      <button onClick={() => setCount((c) => c + 1)}>Increment</button>
      <h3>This is a client component.</h3>
      <div>
        {data}
      </div>
    </div>
  );
};
/Users/himself65/.nvm/versions/node/v18.16.1/bin/npm run build

> affine-waku@0.1.0 build
> waku build

vite v4.3.9 building SSR bundle for production...
✓ 6 modules transformed.
✓ built in 42ms
"default" is not exported by "node_modules/swr/core/dist/react-server.mjs", imported by "src/Counter.tsx".
file: /Users/himself65/Code/affine-waku/src/Counter.tsx:4:7
2: 
3: import { useState } from "react";
4: import useSWR from 'swr'
          ^
5: 
6: export const Counter = () => {
file:///Users/himself65/Code/affine-waku/node_modules/rollup/dist/es/shared/node-entry.js:2124
        base = Object.assign(new Error(base.message), base);
                             ^

Error [RollupError]: "default" is not exported by "node_modules/swr/core/dist/react-server.mjs", imported by "src/Counter.tsx".
    at error (file:///Users/himself65/Code/affine-waku/node_modules/rollup/dist/es/shared/node-entry.js:2124:30)
    at Module.error (file:///Users/himself65/Code/affine-waku/node_modules/rollup/dist/es/shared/node-entry.js:13463:16)
    at Module.traceVariable (file:///Users/himself65/Code/affine-waku/node_modules/rollup/dist/es/shared/node-entry.js:13884:29)
    at ModuleScope.findVariable (file:///Users/himself65/Code/affine-waku/node_modules/rollup/dist/es/shared/node-entry.js:12429:39)
    at ReturnValueScope.findVariable (file:///Users/himself65/Code/affine-waku/node_modules/rollup/dist/es/shared/node-entry.js:6965:38)
    at ChildScope.findVariable (file:///Users/himself65/Code/affine-waku/node_modules/rollup/dist/es/shared/node-entry.js:6965:38)
    at Identifier.bind (file:///Users/himself65/Code/affine-waku/node_modules/rollup/dist/es/shared/node-entry.js:8127:40)
    at CallExpression.bind (file:///Users/himself65/Code/affine-waku/node_modules/rollup/dist/es/shared/node-entry.js:5738:23)
    at CallExpression.bind (file:///Users/himself65/Code/affine-waku/node_modules/rollup/dist/es/shared/node-entry.js:9680:15)
    at VariableDeclarator.bind (file:///Users/himself65/Code/affine-waku/node_modules/rollup/dist/es/shared/node-entry.js:5738:23) {
  binding: 'default',
  code: 'MISSING_EXPORT',
  exporter: '/Users/himself65/Code/affine-waku/node_modules/swr/core/dist/react-server.mjs',
  id: '/Users/himself65/Code/affine-waku/src/Counter.tsx',
  url: 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module',
  pos: 103,
  loc: {
    column: 7,
    file: '/Users/himself65/Code/affine-waku/src/Counter.tsx',
    line: 4
  },
  frame: '2: \n' +
    '3: import { useState } from "react";\n' +
    "4: import useSWR from 'swr'\n" +
    '          ^\n' +
    '5: \n' +
    '6: export const Counter = () => {',
  watchFiles: [
    '/Users/himself65/Code/affine-waku/entries.ts',
    '/Users/himself65/Code/affine-waku/package.json',
    '/Users/himself65/Code/affine-waku/node_modules/waku/dist/server.js',
    '/Users/himself65/Code/affine-waku/src/App.tsx',
    '/Users/himself65/Code/affine-waku/src/Counter.tsx',
    '/Users/himself65/Code/affine-waku/node_modules/swr/core/dist/react-server.mjs',
    '/Users/himself65/Code/affine-waku/node_modules/swr/_internal/dist/react-server.mjs'
  ]
}

Node.js v18.16.1

Process finished with exit code 1

Upstream: vercel/swr#2700


repo: https://github.com/himself65/affine-waku/blob/issue-swr/src/Counter.tsx

yarn install
yarn build

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions