Open raybellis opened 1 month ago
Describe the bug The build system has development dependencies on NodeJS modules for which no FreeBSD-x64 native builds exists
To Reproduce Steps to reproduce the behavior:
Follow the standard build instructions from README.md to the letter.
Expected behavior
A clean build? ;)
Screenshots
Rollup issue Rollup has no native build on FreeBSD - a WASM build is required instead
% pnpm run build:etherpad ... > tsc && vite build --outDir ../src/templates/admin --emptyOutDir /var/home/etherpad/etherpad-lite-2.2.5/node_modules/.pnpm/rollup@4.24.0/node_modules/rollup/dist/native.js:84 throw new Error( ^ Error: Your current platform "freebsd" and architecture "x64" combination is not yet supported by the native Rollup build. Please use the WASM build "@rollup/wasm-node" instead. ...
Vite React SWC plugin issue vitejs/plugin-react-swc also has some native dependency, and tries to load a non-existent
@swc/core-wasm32-wasi
module if that's not found.% pnpm run build:etherpad ... > tsc && vite build --outDir ../src/templates/admin --emptyOutDir failed to load config from /var/home/etherpad/etherpad-lite-2.2.5/admin/vite.config.ts error during build: ...
Server (please complete the following information):
- Etherpad version: 2.2.5
- OS: FreeBSD 14.1
- Node.js version (
node --version
): v20.15.1- npm version (
npm --version
): 10.8.1- pnpm version (
pnpm --version
): 9.12.0- Is the server free of plugins: Yes
Desktop (please complete the following information): N/A
Smartphone (please complete the following information): N/A
Fixes
I don't necessarily propose that these should be adopted universally, but they're what worked for me. That said, they should work universally at the expense of a little build time. They tell Rollup to use the WASM compiler, and use the standard Vite React plugin instead of the SWC version:
diff --git a/package.json b/package.json index d4e94f017..9432ec822 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,11 @@ "type": "git", "url": "https://github.com/ether/etherpad-lite.git" }, + "pnpm": { + "overrides": { + "rollup": "npm:@rollup/wasm-node" + } + }, "version": "2.2.5", "license": "Apache-2.0" } diff --git a/admin/package.json b/admin/package.json index f0d52d2ac..9f2f849f0 100644 --- a/admin/package.json +++ b/admin/package.json @@ -20,7 +20,7 @@ "@types/react-dom": "^18.2.25", "@typescript-eslint/eslint-plugin": "^8.6.0", "@typescript-eslint/parser": "^8.6.0", - "@vitejs/plugin-react-swc": "^3.5.0", + "@vitejs/plugin-react": "^4.3.2", "eslint": "^9.10.0", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.12", diff --git a/admin/vite.config.ts b/admin/vite.config.ts index 23921ca85..4ee4f01be 100644 --- a/admin/vite.config.ts +++ b/admin/vite.config.ts @@ -1,5 +1,5 @@ import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react-swc' +import react from '@vitejs/plugin-react' import svgr from 'vite-plugin-svgr' import {viteStaticCopy} from "vite-plugin-static-copy";
After applying this patch it's necessary to remove
pnpm-lock.json
before runningpnpm i
.
Thanks for the issue. I'll let this open so other can see this easily. I've checked every major bundler like esbuild, rspack etc. They all don't have a native runtime for building the UI which is kind of bad.
@SamTV12345
They all don't have a native runtime for building the UI which is kind of bad
Do you mean specifically for FreeBSD x86?
Arguably as nominally "pure" JS code it would make sense for Etherpad to be able to run everywhere that Node does, without having build-time dependencies on native binaries. I presume there's no such run-time dependencies?
@SamTV12345
They all don't have a native runtime for building the UI which is kind of bad
Do you mean specifically for FreeBSD x86?
Arguably as nominally "pure" JS code it would make sense for Etherpad to be able to run everywhere that Node does, without having build-time dependencies on native binaries. I presume there's no such run-time dependencies?
Unfortunately not. There is webpack that is written in pure JS. But it's so slow that you can't use it anymore with all the hundreds of packages. Only legacy libraries and applications use it. On the other hand you have these shiny new Rust and Go native packager but they are platform dependent. I was surprised that Vite can't build on every platform.
Vite is fine if you tell (p)npm to use @rollup/wasm-node
instead of a native rollup binary. (It's the special SWC version of the React plugin that's the problem).
Unfortunately it appears to be impossible to build even @rollup/wasm-node
directly on FreeBSD itself because it has a development-dependency on wasm-pack
which in turn requires FreeBSD native binaries, and so the cycle continues...
Vite is fine if you tell (p)npm to use
@rollup/wasm-node
instead of a native rollup binary. (It's the special SWC version of the React plugin that's the problem).Unfortunately it appears to be impossible to build even
@rollup/wasm-node
directly on FreeBSD itself because it has a development-dependency onwasm-pack
which in turn requires FreeBSD native binaries, and so the cycle continues...
I couldn't really find a solution to this. I could go back to webpack but it is so slow and hard to setup.
The patch I supplied works for FreeBSD. I think if it was to be deployed for other architectures it just means that compilation will use the "not quite as fast" non-native compilers. On the modest VM on which I installed 2.2.5 the compilation was still a lot faster than the older pre-TS build process. I didn't time it but I think it was under 30 seconds.
But even with the patches you won't have esbuild for hosting the UI don't you?
I don't understand the question. With the patches above I have a fully operational Etherpad server running from the sources downloaded from GitHub.
Oh which version do you run on?
Etherpad 2.2.5 on FreeBSD 14.1
Describe the bug The build system has development dependencies on NodeJS modules for which no FreeBSD-x64 native builds exists
To Reproduce Steps to reproduce the behavior:
Follow the standard build instructions from README.md to the letter.
Expected behavior
A clean build? ;)
Screenshots
Rollup issue Rollup has no native build on FreeBSD - a WASM build is required instead
Vite React SWC plugin issue vitejs/plugin-react-swc also has some native dependency, and tries to load a non-existent
@swc/core-wasm32-wasi
module if that's not found.Server (please complete the following information):
node --version
): v20.15.1npm --version
): 10.8.1pnpm --version
): 9.12.0Desktop (please complete the following information): N/A
Smartphone (please complete the following information): N/A
Fixes
I don't necessarily propose that these should be adopted universally, but they're what worked for me. That said, they should work universally at the expense of a little build time. They tell Rollup to use the WASM compiler, and use the standard Vite React plugin instead of the SWC version:
After applying this patch it's necessary to remove
pnpm-lock.json
before runningpnpm i
.