maglevhq / maglev-core

Ruby on Rails website builder
https://www.maglev.dev
MIT License
273 stars 47 forks source link

Getting Started failing for Node v18; but works for v16 #33

Closed drnic closed 1 year ago

drnic commented 1 year ago

Update: the installation requires Node v16, and fails for Node v18.

Running the "Short version" quick start (with importmaps) is currently failing; with the following error somewhere in the logs.

At various points I see this repeated:

Missing theme file(s) in /Users/drnic/workspace/maglev-demo/my-awesome-site/app/theme
Missing theme file(s) in /Users/drnic/workspace/maglev-demo/my-awesome-site/app/theme

For the yarn install there is this error:

yarn install v1.22.19
[1/4] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 0.18s.
Compiling...
Compilation failed:
Browserslist: caniuse-lite is outdated. Please run:
  npx browserslist@latest --update-db
  Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
node:internal/crypto/hash:71
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (/Users/drnic/.rvm/gems/ruby-3.1.2/gems/maglevcms-1.0.0/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/drnic/.rvm/gems/ruby-3.1.2/gems/maglevcms-1.0.0/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/Users/drnic/.rvm/gems/ruby-3.1.2/gems/maglevcms-1.0.0/node_modules/webpack/lib/NormalModule.js:471:10)
    at /Users/drnic/.rvm/gems/ruby-3.1.2/gems/maglevcms-1.0.0/node_modules/webpack/lib/NormalModule.js:503:5
    at /Users/drnic/.rvm/gems/ruby-3.1.2/gems/maglevcms-1.0.0/node_modules/webpack/lib/NormalModule.js:358:12
    at /Users/drnic/.rvm/gems/ruby-3.1.2/gems/maglevcms-1.0.0/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/Users/drnic/.rvm/gems/ruby-3.1.2/gems/maglevcms-1.0.0/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at iterateNormalLoaders (/Users/drnic/.rvm/gems/ruby-3.1.2/gems/maglevcms-1.0.0/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
    at /Users/drnic/.rvm/gems/ruby-3.1.2/gems/maglevcms-1.0.0/node_modules/loader-runner/lib/LoaderRunner.js:236:3
    at context.callback (/Users/drnic/.rvm/gems/ruby-3.1.2/gems/maglevcms-1.0.0/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at /Users/drnic/.rvm/gems/ruby-3.1.2/gems/maglevcms-1.0.0/node_modules/babel-loader/lib/index.js:59:71
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v18.7.0

Later, when you visit http://localhost:3000/maglev/editor/en/index the error is:

image

This failure occurs for importmaps, esbuild, and webpacker.

Full logs for importmaps (default) https://gist.github.com/drnic/dc8790d4141b2db615a9d9ba90a1a2ac

Perhaps unrelated but noted: even though it is importmaps by default, the logs include rake maglev:webpacker:compile

In the logs it appears I was using node v18.7.0, but it also failed for latest node 18 v18.12.0

OOOh, it works for node v16!

did commented 1 year ago

👋 @drnic, thanks A LOT for the bug report.

Unfortunately, I tested it everything against node 16 and to be honest, I wasn't even aware of node 18.

Anyway, since I was going to drop webpacker and use vite-rails instead, I'm wondering if this could help me to tackle this issue at the same time...

wdiechmann commented 1 year ago

@did vite-rails gets a lot of attention - it may be a brilliant idea - webpacker seems to be 'out the window' so I guess you've got some deciding to do 😄

Personally I'd probably stay as close to 'vanilla Rails' for as long as possible (that would currently ax vite-rails and let importmaps et al slip in through the "escape hatch"

did commented 1 year ago

@wdiechmann, staying as close to "vanilla Rails" was the path I've been trying to follow. But, since I took the decision to build the EditorUI in full VueJS for a very specific strategy purpose (that's more or a less a bet), it's going to hard to be full "vanilla Rails" for this part.

Anyway, I wasn't really satisfied by webpacker (pretty slow, tons of plugins), neither by importmaps too. Besides the few tests I ran with vite-rails convinced me that this was the best solution right now in the Rails world to manage assets...well, of course, until someone releases a new fancy wither than white detergent transpiler/transformer/bundler tool. And this is already the case with https://turbo.build. The JS world is like kinda wild.

wdiechmann commented 1 year ago

@did 😂 all that JS is like heroin — once you’re hooked there is no way back 😉

Did try adding vite-rails to a new rails with nothing to show for it - will keep an eye out for how it fares but am not too optimistic 🤕

Believe the trick to building for the Rails eco-system is avoiding all the ‘tinkering’ which immediately leaves your code vulnerable to “dependency hell”

But, ‘the 🎲 are cast’ - so forward with vite and VueJS 😊

Cheers Walther

Den 28. okt. 2022 kl. 23.18 skrev Didier Lafforgue @.***>:

 @wdiechmann, staying as close to "vanilla Rails" was the path I've been trying to follow. But, since I took the decision to build the EditorUI in full VueJS for a very specific strategy purpose (that's more or a less a bet), it's going to hard to be full "vanilla Rails" for this part.

Anyway, I wasn't really satisfied by webpacker (pretty slow, tons of plugins), neither by importmaps too. Besides the few tests I ran with vite-rails convinced me that this was the best solution right now in the Rails world to manage assets...well, of course, until someone releases a new fancy wither than white detergent transpiler/transformer/bundler tool. And this is already the case with https://turbo.build. The JS world is like kinda wild.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

did commented 1 year ago

the in progress PR -> https://github.com/maglevhq/maglev-core/pull/35

did commented 1 year ago

@wdiechmann I totally agree with you.

My ultimate goal is/was to port Maglev to other web frameworks in other languages (Laravel, ExpressJS, Phoenix, ...etc). Basically my main idea was to drop the Editor compiled (transpiled or whatever you name it) files in a new application and implement the Maglev API routes. I recognize it's kinda naive :-)

did commented 1 year ago

Alright, I've released a new version of MaglevCMS which now runs Vite to compile/transform/bundle the assets (instead of Webpack/Webpacker). This version also runs smoothly with Node.js 18 (I also setup a CD/CI testing the project against Node 16 & 18). One last point, no more Missing theme file(s) in /Users/drnic/workspace/maglev-demo/my-awesome-site/app/theme warnings during the installation.

Thanks again @drnic (and @wdiechmann)

drnic commented 1 year ago

Awesome work @did

wdiechmann commented 1 year ago

This is tremendous - I'm so going to dig deeper into this!! Well done @did