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

[Next.js] Module not found: Can't resolve './' #111

Open
satelllte opened this issue Jun 4, 2024 · 3 comments
Open

[Next.js] Module not found: Can't resolve './' #111

satelllte opened this issue Jun 4, 2024 · 3 comments
Labels
bug Something isn't working Next.js wasm
Milestone

Comments

@satelllte
Copy link

Hi 👋🏻
The lib fails in Next.js with the following error on any import from @react-three/jolt:

./node_modules/jolt-physics/dist/jolt-physics.wasm-compat.js:12:121
Module not found: Can't resolve './'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/@react-three/jolt/dist/index.mjs
./src/components/Scene/PhysicsDemo/PhysicsDemo.tsx

Example:

import {useEffect} from 'react';
import {Physics} from '@react-three/jolt';

export function PhysicsDemo() {
  return (
    <Physics>
      <InnerComponents/>
    </Physics>
  );
}

Have you ever experienced such issue?

@DennisSmolek
Copy link
Collaborator

@isaac-mason is this some kind of WASM/Next.js issue?

@DennisSmolek DennisSmolek added bug Something isn't working wasm Next.js labels Jun 6, 2024
@DennisSmolek DennisSmolek added this to the 0.0 Alpha milestone Jun 6, 2024
@r00ott
Copy link

r00ott commented Jun 23, 2024

Hi 👋🏻

This issue likely stems from how Next.js handles module resolution for WebAssembly files. To fix it, try adding the following to your next.config.js:

const nextConfig = {
  webpack: (config, { isServer }) => {
    if (!isServer) {
      config.experiments = { asyncWebAssembly: true };
    }
    return config;
  },
};

module.exports = nextConfig;

Ensure all dependencies are correctly installed:

npm install @react-three/jolt

If the issue persists, check the https://nextjs.org/docs/messages/module-not-found for further guidance.

Have you encountered this issue before or found a solution that works? Any additional details could help narrow down the problem.

@satelllte
Copy link
Author

satelllte commented Jun 23, 2024

Hi @r00ott 👋🏻
I haven't found any solution yet and I encountered this issue every time I tried to use Jolt with Next.js.

I've created a quick repo with jolt branch which reproduces it:
satelllte/react-three-next-jolt#1

Tried to install Jolt and set asyncWebAssembly, now it fails with the same error if I'm trying to do npm run build, but if I try to run it in development via npm run dev, the dev server gets stuck with Compiling / ... message for ever, unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Next.js wasm
Projects
None yet
Development

No branches or pull requests

3 participants