cocalc icon indicating copy to clipboard operation
cocalc copied to clipboard

support building cocalc using nodejs version 18

Open williamstein opened this issue 3 years ago • 4 comments

The build currently fails building the frontend using webpack. We hit exactly this bug:

https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported

There's a workaround there to add a command line flag to node.

williamstein avatar Aug 01 '22 19:08 williamstein

The first big issue I hit with trying to use node v18 to build CoCalc is that they removed the md4 crypto algorithm, which breaks webpack. Amusingly, the solution webpack has for the problem is reintroduce md4 back to webpack by getting some AssemblyScript version of it! https://github.com/webpack/webpack/pull/14584. It's quite cool. Once compiled, the actual code is just a tiny little base64 string burried in the minified js that gets loaded on the fly. Unfortunately, the exact same bug is also in the file-loader webpack plugin, which got deprecated, so I also need to rewrite cocalc to not use that. But that's a good thing to do anyways.

So next step -- switch from using file-loader to using the asset modules, as suggested here: https://github.com/webpack-contrib/file-loader#readme

I used asset modules for my python-wasm examples here, and they are easy: https://github.com/sagemathinc/python-wasm/blob/main/packages/webpack/webpack.config.js#L35

williamstein avatar Aug 01 '22 20:08 williamstein

Now everything builds. However, running locally on MacOS (no virtualization or linux), the hub is not connecting to projects, though the project is running and accepting connections.

williamstein avatar Aug 02 '22 05:08 williamstein

Confirmed -- switching back to node 16 and rebuilding immediately fixed the problem.

williamstein avatar Aug 02 '22 05:08 williamstein

Another update. I just did a 100% clean build from scratch on a clean Ubuntu 22.04 image (on aarch64 linux) with node 18 and Postgres 14, and everything worked perfectly, including connecting to projects. So maybe that's not a problem, and it's just caused by stuff left laying around in the above case.

williamstein avatar Aug 02 '22 21:08 williamstein

obviously fixed long ago

williamstein avatar Nov 25 '23 22:11 williamstein