cubing / cubing.js

🛠 A library for displaying and working with twisty puzzles. Also currently home to the code for Twizzle.
https://js.cubing.net/cubing/
GNU General Public License v3.0
232 stars 42 forks source link

[cubing.js issue] Not compatible with nextjs #298

Closed bryanlundberg closed 8 months ago

bryanlundberg commented 8 months ago

Steps to reproduce the issue

  1. npx create-next-app@latest
  2. npm install cubing
  3. replace default page with a basic usage
"use client";
import { useState, useEffect } from "react";
import { randomScrambleForEvent } from "cubing/scramble";

export default function App() {
  const [scrambleString, setScrambleString] = useState("");

  function genScramble() {
    randomScrambleForEvent("sq1").then((scramble) => {
      const scrambleStr = scramble.toString();
      setScrambleString(scrambleStr);
    });
  }
  useEffect(() => genScramble(), []);

  return (
    <>
      <button onClick={() => genScramble()}>genScramble</button>
      <p>{scrambleString}</p>
    </>
  );
}

Observed behaviour

Error: Javascript and Typescript versions.

🖼 Screenshots

image

Expected behaviour

Click the button a generate a scramble.

Environment

node 20

Additional info

same code using vite app, works fine.

lgarron commented 8 months ago

This is due to some unfortunate interactions between ecosystem tools.

At the moment we can't use that line, and taking it out seems to prevent Next from trying to locate it. I'll remove it from the published code for now.

lgarron commented 8 months ago

Alright, please try with v0.43.8. Thanks for the report!