Closed mauricedb closed 6 months ago
Seems like SSR feature cause this bug
This might be a React issue. I'm trying to give it an implement mini minimum reproduction.
Seems like SSR feature cause this bug
Please try removing --with-ssr
to see how it changes.
When I start the dev server using npx waku dev
there is no error and the app starts just fine.
With npx waku build
there is still an error: You did not run Node.js with the
--conditions react-serverflag. Any "react-server" override will only work with ESM imports.
Complete output:
PS C:\Temp\waku-project> npx waku build
vite v4.5.0 building SSR bundle for production...
✓ 33 modules transformed.
✓ built in 624ms
vite v4.5.0 building SSR bundle for production...
✓ 6 modules transformed.
dist/assets/waku-client.js 0.23 kB
dist/assets/rsc1-ca17757ec.js 0.57 kB
dist/assets/App-fb1b7d37.js 0.81 kB
dist/entries.js 1.14 kB
dist/assets/rsc0-7d99752b9.js 11.43 kB
✓ built in 89ms
vite v4.5.0 building for production...
✓ 38 modules transformed.
../dist/public/index.html 1.41 kB │ gzip: 0.63 kB
../dist/public/assets/rsc0-7d99752b9.js 0.19 kB │ gzip: 0.16 kB
../dist/public/assets/waku-client.js 0.19 kB │ gzip: 0.16 kB
../dist/public/assets/rsc1-ca17757ec.js 0.39 kB │ gzip: 0.28 kB
../dist/public/assets/jsx-runtime-d5aecd7e.js 0.67 kB │ gzip: 0.43 kB
../dist/public/assets/main-173a10a9.js 1.09 kB │ gzip: 0.61 kB
../dist/public/assets/index-6fca7d3f.js 7.37 kB │ gzip: 2.85 kB
../dist/public/assets/client-01c116b8.js 193.38 kB │ gzip: 60.92 kB
✓ built in 680ms
You did not run Node.js with the `--conditions react-server` flag. Any "react-server" override will only work with ESM imports.
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<Object>".] {
code: 'ERR_UNHANDLED_REJECTION'
}
Node.js v20.9.0
PS C:\Temp\waku-project>
Seems like SSR feature cause this bug
Please try removing
--with-ssr
to see how it changes.
I debug the code for few hours. The main reason is path.join
will cause c://path/to/file
and used by import(specifier)
in React
There are many usage of path.join
and other similar codes. I think I need few days to correct the code
After finishing #165, my plan is to reduce Node specific code in our code, and maybe create a DI-able function. (Handling "react-server" and Vite still depend on Node.) That will take months, so just saying for now.
After finishing #165, my plan is to reduce Node specific code in our code, and maybe create a DI-able function. (Handling "react-server" and Vite still depend on Node.) That will take months, so just saying for now.
This is a nice idea. If so, I think the better way is to support prod in some other environment (deno, bun, cloudflare workers) firstly. So that
to support prod in some other environment
Yes, that's the goal, but impossible at the moment anyway because we use --conditions react-server
with new Worker()
. Do you know if other environment supports it? cc @gregberge also has interests in it.
If we can bundle all packages into one file or files that acceptable by other environments
I think it already does that in terms of bundling.
Step taken:
Setting up project was fine
Next cd into project and try to start the development server with
npm run dev
Resulting console output when opening http://localhost:3000/ in the browser:
Environment: