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

Vite throws Uncaught ReferenceError: regeneratorRuntime is not defined when using cache #337

Closed
wsfuller opened this issue Oct 12, 2022 · 1 comment

Comments

@wsfuller
Copy link

Describe the bug

Having bug when trying to use SimpleCache with Vite. My route runs as expected when not use cache, but as soon as it's used get the following error:

Screen Shot 2022-10-12 at 3 24 33 PM

First example will be working, second will be what throws the error

App.tsx (working without simple cache)

const routes: Route[] = [
  {
    path: "/",
    element: <Home />,
  },
  {
    path: "items",
    element: <Items />,
    loader: async () => ({
      items: await getItems(),
    }),
    pendingElement: async () => (<div>...</div>),
    pendingMs: 1000,
  }
];

function App() {
  return (
    <div className="App">
      <Router routes={routes} location={location}>
        <Root />
        <ReactLocationDevtools initialIsOpen={false} />
      </Router>
    </div>
  );
}

export default App;
App.tsx (breaks using simple cache)

import { ReactLocationSimpleCache } from "@tanstack/react-location-simple-cache";

const routeCache = new ReactLocationSimpleCache();

const routes: Route[] = [
  {
    path: "/",
    element: <Home />,
  },
  {
    path: "items",
    element: <Items />,
    loader: routeCache.createLoader(async () => ({
      items: await getItems(),
    })),
    pendingElement: async () => (<div>...</div>),
    pendingMs: 1000,
  }
];

function App() {
  return (
    <div className="App">
      <Router routes={routes} location={location}>
        <Root />
        <ReactLocationDevtools initialIsOpen={false} />
      </Router>
    </div>
  );
}

export default App;

I've tried using the suggestions in #227 with using regeneratorRuntime at the top level of the app but that doesn't seem to do anything.

Opening this bug here as it only happens when using SimpleCache and doesn't get thrown otherwise

Your Example Website or App

#227

Steps to Reproduce the Bug or Issue

  1. yarn create vite --template react-ts
  2. yarn
  3. yarn add @tanstack/react-location @tanstack/react-location-simple-cache
  4. Wrap working loader in cache

Expected behavior

Would assume following the docs this would work 🤷

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: 106

Additional context

No response

@tannerlinsley
Copy link
Collaborator

You'll need to include the babel runtime.

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

No branches or pull requests

2 participants