-
Notifications
You must be signed in to change notification settings - Fork 37
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
Seems like Next.js is not working #151
Comments
Confirmed. I can replicate like this:
Then in
... to enable wp5 support per https://nextjs.org/blog/next-9-5#webpack-5-support-beta. Then
I think since this blocks anyone creating a cjs app it's a p1. @arv I see the flag in webpack-build, but not sure how you want to setup the output. |
Did some exploring. If we generate
Next.js is running in a Node.js environment without a lot of DOM. I think we will also run into trouble with |
I’m so lost - why are we running in a node environment? |
Next.js tries to run the js on the server, it is what is so special about next.js. I will try to switch to dynamic import and see how that plays out. |
We can check |
This needs to be re-opened, right? |
Getting closer... Turns out I have to use yarn for Now it replaces the new URL('./path/file.wasm', import.meta.url); That look much better and becomes Then I tried using // next.config.js
module.exports = {
webpack: (config, options) => {
config.module.rules.push({
test: /\.wasm/,
use: ["file-loader"],
});
return config;
},
}; Could not resolve
Still getting 404. Maybe @elsigh has any idea what I am missing? |
I was able to hack this to work horribly with the following steps:
Basically, I tell Replicache the URL to find the wasm file at specifically rather than trying to derive it from This is not ideal, but works for now. |
Where did you put this? I can't replicate your steps here.
I wonder if https://github.com/vercel/next.js/blob/canary/examples/with-webassembly/next.config.js |
I modified the generated code in replicache_client.js but we can do the same thing one layer higher up. I tried using More later... |
And yes, manually putting things in public works for me too |
There are a bunch of Webpack/Next.js issues to work around: - `import.meta.url` generates `file:` URL. Using the `new URL` pattern tells Webpack to do runtime URLs. - `experimental.asyncWebAssembly` causes Webpack to parse the wasm file and validate imports which it doesn't do correctly. Instead you need to use `type: "asset/resource"`. - But this puts the wasm file in `_next` which cause 404. We need to tell webpack to put the file in `static/` too Towards rocicorp#151
There are a bunch of Webpack/Next.js issues to work around: - `import.meta.url` generates `file:` URL. Using the `new URL` pattern tells Webpack to do runtime URLs. - `experimental.asyncWebAssembly` causes Webpack to parse the wasm file and validate imports which it doesn't do correctly. Instead you need to use `type: "asset/resource"`. - But this puts the wasm file in `_next` which cause 404. We need to tell webpack to put the file in `static/` too Towards #151
Calling this done for now. We will see if we need to resurface a cjs build in the future. |
@elsigh tried to use Replicache in a nextjs app and just imported it through npm the naive way. It correctly resolved to the cjs bundle, but the cjs bundle contains code with
export
which doesn't seem correct.This blocks @elsigh from trying Replicache. We should maybe make a sample nextjs app to ensure this works.
The text was updated successfully, but these errors were encountered: