hydra-synth / hydra

Livecoding networked visuals in the browser
https://hydra.ojack.xyz
GNU Affero General Public License v3.0
2.13k stars 255 forks source link

web-editor build fail due to hydra-synth #247

Closed micuat closed 1 year ago

micuat commented 1 year ago
hydrogen@blackmirror:~/hydra/frontend/web-editor$ /home/hydrogen/.nvm/versions/node/v12.18.3/bin/yarn build
yarn run v1.22.19
warning package.json: License should be a valid SPDX license expression
$ browserify ./index.js --debug -o ./public/bundle.js && npm run uglify
Error: Parsing file /home/hydrogen/hydra/node_modules/hydra-synth/src/index.js: 'import' and 'export' may appear only with 'sourceType: module' (1:0)
    at Deps.parseDeps (/home/hydrogen/hydra/node_modules/module-deps/index.js:519:15)
    at getDeps (/home/hydrogen/hydra/node_modules/module-deps/index.js:447:44)
    at /home/hydrogen/hydra/node_modules/module-deps/index.js:430:38
    at ConcatStream.<anonymous> (/home/hydrogen/hydra/node_modules/concat-stream/index.js:37:43)
    at ConcatStream.emit (events.js:412:35)
    at finishMaybe (/home/hydrogen/hydra/node_modules/readable-stream/lib/_stream_writable.js:630:14)
    at endWritable (/home/hydrogen/hydra/node_modules/readable-stream/lib/_stream_writable.js:638:3)
    at ConcatStream.Writable.end (/home/hydrogen/hydra/node_modules/readable-stream/lib/_stream_writable.js:594:41)
    at DuplexWrapper.onend (/home/hydrogen/hydra/node_modules/readable-stream/lib/_stream_readable.js:577:10)
    at Object.onceWrapper (events.js:519:28)
error Command failed with exit code 1.
micuat commented 1 year ago

I see people suggest using esmify but with browserify ./index.js -p esmify I see same errors :( Is browserify anyways deprecated and we should use something else?

micuat commented 1 year ago

hydra-synth is supposed to be esmifying already, could it be that this part is not working??

micuat commented 1 year ago

I'm giving up investigating this issue because I can't really reproduce the error to determine which hydra-synth started to break this. After all, with any hydra-synth, browserify on web-editor fails on my environment :(

What I suggest is to switch the build environment to something modern like vite. Here is my test using choo and hydra https://glitch.com/edit/#!/choo-hydra-vite

edit: the above project works with serving (vite) but the build doesn't work (vite build)

micuat commented 1 year ago

It seems like this line is causing an error (parent not defined) when I try to

  1. build hydra-synth with vite+rollup
  2. import umd build with script tag

https://github.com/hydra-synth/hydra-synth/blob/125372fd74ad932efdcc2f9d8c4eca3536b30cf0/src/eval-sandbox.js#L18

if I comment it out, it works as normal (I don't know how it works in a live editor)

ojack commented 1 year ago

fixed for now by creating a separate glsl-functions file. I think we should still investigate all of this though!