Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
raybellis opened this issue Oct 5, 2024 · 10 comments
Open

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

raybellis opened this issue Oct 5, 2024 · 10 comments

Comments

@raybellis
Copy link
Contributor

raybellis commented Oct 5, 2024

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.

@SamTV12345
Copy link
Member

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.

@raybellis
Copy link
Contributor Author

raybellis commented Oct 9, 2024

@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
Copy link
Member

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

@raybellis
Copy link
Contributor Author

raybellis commented Oct 9, 2024

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

@SamTV12345
Copy link
Member

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.

@raybellis
Copy link
Contributor Author

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.

@SamTV12345
Copy link
Member

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

@raybellis
Copy link
Contributor Author

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

@SamTV12345
Copy link
Member

Oh which version do you run on?

@raybellis
Copy link
Contributor Author

Etherpad 2.2.5 on FreeBSD 14.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@raybellis @SamTV12345 and others