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

.default is not a function with Remix app & various bundlers: bun & vite/ rollup #242

Open
reillyjodonnell opened this issue Sep 10, 2024 · 1 comment · May be fixed by #249
Open

.default is not a function with Remix app & various bundlers: bun & vite/ rollup #242

reillyjodonnell opened this issue Sep 10, 2024 · 1 comment · May be fixed by #249

Comments

@reillyjodonnell
Copy link

reillyjodonnell commented Sep 10, 2024

When running in a remix app with bun I see this error:

TypeError: (0 , import_react_use_websocket.default) is not a function

To make sure this wasn't a bun issue I created a new remix app with npm via:

npx create-remix@latest then ran npm i react-use-websocket and imported it in a component by updating app/routes/_index.tsx to :

import type { MetaFunction } from '@remix-run/node';
import useWebSocket from 'react-use-websocket';

export const meta: MetaFunction = () => {
  return [
    { title: 'New Remix App' },
    { name: 'description', content: 'Welcome to Remix!' },
  ];
};


export default function Index() {

  const {} = useWebSocket('ws://localhost:3000/ws');
  return (
    <div className="font-sans p-4">
      <h1 className="text-3xl">Welcome to Remix</h1>
      <ul className="list-disc mt-4 pl-6 space-y-2">
        <li>
          <a
            className="text-blue-700 underline visited:text-purple-900"
            target="_blank"
            href="https://remix.run/start/quickstart"
            rel="noreferrer"
          >
            5m Quick Start
          </a>
        </li>
        <li>
          <a
            className="text-blue-700 underline visited:text-purple-900"
            target="_blank"
            href="https://remix.run/start/tutorial"
            rel="noreferrer"
          >
            30m Tutorial
          </a>
        </li>
        <li>
          <a
            className="text-blue-700 underline visited:text-purple-900"
            target="_blank"
            href="https://remix.run/docs"
            rel="noreferrer"
          >
            Remix Docs
          </a>
        </li>
      </ul>
    </div>
  );
}

and get the following error when running via npm run dev:

TypeError: __vite_ssr_import_1__.default is not a function
    at Index (/Users/reilly/trash/app/routes/_index.tsx:12:14)
    at renderWithHooks (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:5724:16)
    at renderIndeterminateComponent (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:5798:15)
    at renderElement (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:6023:7)
    at renderNodeDestructiveImpl (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:6181:11)
    at renderNodeDestructive (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:6153:14)
    at renderContextProvider (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:5997:3)
    at renderElement (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:6094:11)
    at renderNodeDestructiveImpl (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:6181:11)
    at renderNodeDestructive (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:6153:14)
TypeError: __vite_ssr_import_1__.default is not a function
    at Index (/Users/reilly/trash/app/routes/_index.tsx:12:14)
    at renderWithHooks (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:5724:16)
    at renderIndeterminateComponent (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:5798:15)
    at renderElement (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:6023:7)
    at renderNodeDestructiveImpl (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:6181:11)
    at renderNodeDestructive (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:6153:14)
    at renderContextProvider (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:5997:3)
    at renderElement (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:6094:11)
    at renderNodeDestructiveImpl (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:6181:11)
    at renderNodeDestructive (/Users/reilly/trash/node_modules/react-dom/cjs/react-dom-server.node.development.js:6153:14)

The basic remix example doesn't work with any of the major 4 package managers: npm, yarn, pnpm, and bun.

@reillyjodonnell reillyjodonnell changed the title .default is not a function with Remix app & with different bundlers (bun/ vite (rollup)) .default is not a function with Remix app & various bundlers: bun & vite/ rollup Sep 10, 2024
@uplusion23
Copy link

Same issue here, using a new Vite / React app

@reillyjodonnell reillyjodonnell linked a pull request Oct 30, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants