You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use Rsbuild environment API to build a client and a server. I enforce ESM output on both environments and have module: "module" in my package.json. But Rspack trying to execute that file in CJS environment, because it requires mjs extension.
After these changes I managed to run my server in ESM mode I've got this error:
queueMicrotask undefined
I assume this is something related to vmContext. I fixed this issue by manually patching queueMicrotask for the dependencies failing. I probably should have done that in my entry files as it will be needed in the future for other deps.
Even though commands are identical (except entry files), server/index.tsx missing PUBLIC environment variables defined in .env.development and throw process undefined error.
As a workaround, I manually load environment variables during to ssr environment:
@sibbng Thank you for providing such a detailed description of the problem.
Automatic load env is a capability provided by the Rsbuild CLI, activated when you execute the rsbuild dev / rsbuild build .
When utilizing the Environment API, you need explicitly invoke the loadEnv method. Apologies for the oversight in our documentation; I will ensure it is updated accordingly.
Version
System: OS: Windows 10 10.0.19042 CPU: (4) x64 Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz Memory: 1.94 GB / 7.83 GB Browsers: Edge: Spartan (44.19041.423.0), Chromium (127.0.2651.74) Internet Explorer: 11.0.19041.1 npmPackages: @rsbuild/core: 1.0.1-beta.16 => 1.0.1-beta.16
Details
I use Rsbuild environment API to build a client and a server. I enforce ESM output on both environments and have
module: "module"
in mypackage.json
. But Rspack trying to execute that file in CJS environment, because it requires mjs extension.https://github.com/web-infra-dev/rspack/blob/d9a6d592e5b9cde55391a0e22786817d3bc5b63d/packages/rspack-test-tools/src/runner/runner/esm.ts#L23-L26
I fixed this issue by modifying output filename:
https://github.com/sibbng/voby-ssr-demo/blob/02d98800b11cb0306d8dc6ccb1924903f90ecac0/apps/web/rsbuild.config.ts#L75-L77
After these changes I managed to run my server in ESM mode I've got this error:
queueMicrotask undefined
I assume this is something related to vmContext. I fixed this issue by manually patching queueMicrotask for the dependencies failing. I probably should have done that in my entry files as it will be needed in the future for other deps.
https://github.com/sibbng/voby-ssr-demo/blob/02d98800b11cb0306d8dc6ccb1924903f90ecac0/packages/voby-unplugin/src/index.ts#L189
After pathing all these, I managed to get a working dev and prod environment. But for some reason, environment values are not loaded in dev mode.
https://github.com/sibbng/voby-ssr-demo/blob/02d98800b11cb0306d8dc6ccb1924903f90ecac0/apps/web/package.json#L7-L8
Even though commands are identical (except entry files),
server/index.tsx
missing PUBLIC environment variables defined in .env.development and throwprocess undefined
error.As a workaround, I manually load environment variables during to ssr environment:
https://github.com/sibbng/voby-ssr-demo/blob/9dba96c8d2de3425e11dfbcf707821a7df1605e4/apps/web/rsbuild.config.ts#L67-L72
Reproduce link
https://github.com/sibbng/voby-ssr-demo
Reproduce Steps
process
not defined.The text was updated successfully, but these errors were encountered: