etherpad-lite icon indicating copy to clipboard operation
etherpad-lite copied to clipboard

Etherpad 2.x won't build cleanly on FreeBSD x64

Open raybellis opened this issue 1 year ago • 12 comments

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/[email protected]/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 running pnpm i.

raybellis avatar Oct 05 '24 10:10 raybellis

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/[email protected]/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 running pnpm 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 avatar Oct 09 '24 09:10 SamTV12345

@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?

raybellis avatar Oct 09 '24 10:10 raybellis

@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.

SamTV12345 avatar Oct 09 '24 10:10 SamTV12345

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...

raybellis avatar Oct 09 '24 12:10 raybellis

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...

I couldn't really find a solution to this. I could go back to webpack but it is so slow and hard to setup.

SamTV12345 avatar Oct 28 '24 17:10 SamTV12345

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.

raybellis avatar Oct 28 '24 21:10 raybellis

But even with the patches you won't have esbuild for hosting the UI don't you?

SamTV12345 avatar Oct 28 '24 21:10 SamTV12345

I don't understand the question. With the patches above I have a fully operational Etherpad server running from the sources downloaded from GitHub.

raybellis avatar Oct 28 '24 21:10 raybellis

Oh which version do you run on?

SamTV12345 avatar Oct 28 '24 21:10 SamTV12345

Etherpad 2.2.5 on FreeBSD 14.1

raybellis avatar Oct 28 '24 21:10 raybellis

Confirming the patch works for me as well. Etherpad 2.2.7 FreeBSD 14.1. Thx @raybellis

foudfou avatar Jan 01 '25 21:01 foudfou

The patch worked for me too! Thanks @raybellis !

FreeBSD 14.2 Node 22 Etherpad 2.2.7

devnull-hub-lab avatar Feb 04 '25 21:02 devnull-hub-lab

Just updated to etherpad-lite 2.4.2. FreeBSD 14.3. Updated patch seems to work fine:

diff --git a/admin/package.json b/admin/package.json
index 20723272e..3c6528790 100644
--- a/admin/package.json
+++ b/admin/package.json
@@ -20,7 +20,7 @@
     "@types/react-dom": "^19.1.6",
     "@typescript-eslint/eslint-plugin": "^8.37.0",
     "@typescript-eslint/parser": "^8.37.0",
-    "@vitejs/plugin-react-swc": "^3.10.2",
+    "@vitejs/plugin-react": "^4.7.0",
     "eslint": "^9.31.0",
     "eslint-plugin-react-hooks": "^5.2.0",
     "eslint-plugin-react-refresh": "^0.4.20",
diff --git a/admin/vite.config.ts b/admin/vite.config.ts
index 7b63c9e20..8181a2205 100644
--- a/admin/vite.config.ts
+++ b/admin/vite.config.ts
@@ -1,4 +1,4 @@
 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";

diff --git a/package.json b/package.json
index 05938017d..d43e899c8 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.4.2",
   "license": "Apache-2.0"
 }

Thank you so much @raybellis for sharing in the first place!

foudfou avatar Aug 14 '25 22:08 foudfou