-
Notifications
You must be signed in to change notification settings - Fork 13
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-plugin-preval
messes with Webpack configuration, "'fs' module not found" error
#26
Comments
@ricokahler I think you need to add some config for //webpack.config.js
module.exports = {
...
resolve: {
fallback: {
"fs": false
},
}
} Could you try to load a file that requires the
I've added my own |
I'm having a bit of trouble reproducing this. I recently added a next example app to the alpha branch as well as a build command to rapidly test out scenarios like this. Could you take a look at this branch? I created an example that imports something with In order to run this example on your machine, clone the branch, Let me know if you see any differences in the configuration or set up, very willing to look into this! |
I've also tried to import fs from my own project in a UnlyEd/next-right-now#345 at commit #1 I've made some other tests and it might be my mistake... One of the functions being exported in the file that imports |
it's hard to know without that stack trace so i'm really prioritizing that issue 😓😅 |
Yeah, I can confirm it has nothing to do with next-plugin-preval, it was because one of the function in the file was being used from a file served to the client and bundled using the "browser" Webpack version. I'm closing this! Thanks for your feedback, it really helped me figuring out the true culprit 😅 |
Thanks for this plugin, it helps solving a long-standing pain point with shared/app-wide data.
I've spent several hours working on it today and I have a few feedbacks I hope you'll find useful.
A ran into an issue where depending on how I write some import in my code, it crashes this plugin. I got really lucky there because the error message is crytic and I basically figured it out because I wrote it the right way (using default import) first, and then refactored stuff and used a named import which crashed the whole app. After some digging I found the root cause, but it's a really bad dev experience, and makes the code not resilient to changes. I believe it should be fixed.
I ran into another mind-blowing issue in regard to Webpack, where if I import a function that relies on
fs
, the whole app crashes. This didn't happen before using this plugin. Also, that same "fs" code is actually called by the plugin and it works well. It looks like an edge case. I found a workaround by calling the code directly from the page, which works fine 🤯.👍 Works fine
In Next.js page
In Next.js page
In
getAirtableDataset.ts
The code does basically the same thing, the only difference is the call site which isn't the same file.
This is very odd, too.
Here is the commit where I fixed the bug, might be more helpful to give a raw overview: UnlyEd/next-right-now@a7406f7
@ricokahler All the code I wrote today is open source and available at UnlyEd/next-right-now#334, I can make a repro if you're willing to investigate this issue. 😄
The text was updated successfully, but these errors were encountered: