preactjs / next-plugin-preact

Next.js plugin for preact X
394 stars 9 forks source link

Blank page caused in using-preact example on Windows 10 #20

Closed geisterfurz007 closed 3 years ago

geisterfurz007 commented 3 years ago

I hope I am in the right place here; let me know if I am not.

Background

For the past couple of days I have been trying to get fast-refresh, next.js and Preact to run together. For that I tried using the using-preact example from next.js directly.

Problem / Reproduction

  1. In an empty directory (or any directory that doesn't have a web directory under it) run the following commands:
    npx create-next-app --example using-preact web
    cd web
    yarn dev
  2. Open the browser on http://localhost:3000.
  3. See a blank page
  4. Open the JS Console
  5. See three errors:
    Uncaught TypeError: __webpack_require__(...) is not a function
    js NextJS
    Webpack 20
    react-refresh.js:1796:264
    ---
    Uncaught TypeError: __webpack_require__(...) is not a function
    js NextJS
    Webpack 19
    _app.js:8933:264
    ---
    Uncaught TypeError: __webpack_require__(...) is not a function
    js NextJS
    Webpack 19
    index.js:9043:264

Expected behaviour

The page is displayed properly and no errors come up in the console.

Versions and stuff

OS: Windows 10 64-bit Node: 14.15.3 npm: 6.14.9

Libraries (copied from an attempt to fix things; they aren't identical to the using-preact example but neither of them works)

next: 10.0.5
next-plugin-preact: 3.0.3
preact: 10.5.11
preact-render-to-string: 5.1.12
react: npm:@preact/compat@^0.0.4
react-dom: npm:@preact/compat@^0.0.4

Stuff I tried

Run in a Linux VM. Running the reproduction steps in a Kali VM I had around, worked without problems, fast refresh works without issues. Remove next-plugin-preact from next.config.js. The project displays a working website, a change in source files is detected and triggers a loading icon but the content of the website doesn't change (which makes sense with prefresh not being included, I guess). Copy an older version of next.config.js. They produced the same result as including the plugin directly. Run in WSL. Works just as well with the Kali VM but is a huge pain to set up, check the IP of the WSL VM and is a problem for me because I regularly work with VirtualBox which doesn't allow me to run WSL next to it (so I have to change the Windows Features and restart each time I want to work on the other). Ask a friend to run the reproduction steps on his computer (Windows 10 64-bit as well). Behaves in the same way.

Chances are I am just missing something blatantly obvious here but after days of trying to find an answer to my problem or even someone else with the same issue, I gave up... If there is any information missing, let me know and I will provide it asap!

geisterfurz007 commented 3 years ago

I am not sure why but this does not occur anymore. In a standalone project I am able to run the using-preact example from the next.js repository after installing webpack@4.46.0 as devDependency for the project; still stuck on this in my mono-repo with storybook next to it but I hope I can figure that one out soon enough.