purescript / npm-installer

ISC License
10 stars 13 forks source link

Port to PureScript #5

Open hdgarrood opened 5 years ago

felixSchl commented 5 years ago

Would be interesting to know if the code path for building from sources ever ran on anyone's machine, and if it did if it succeeded. Otherwise, I'd put my vote in for getting rid of it.

hdgarrood commented 5 years ago

I’m pretty sure it has, because there are a fair few operating systems and architectures which we don’t support - anything which isn’t x86_64 windows, mac, or linux. I definitely remember seeing issues opened by people on other platforms.

JordanMartinez commented 8 months ago

I started porting this via https://github.com/JordanMartinez/purs-installer. However, I ran into issues due to the NPM dependencies used, which are still on CJS modules: cacache. I think everything else is otherwise fine.

rhendric commented 8 months ago

What issues? (Not in a good place to clone and try your repo right now, sorry.)

JordanMartinez commented 8 months ago

What issues? (Not in a good place to clone and try your repo right now, sorry.)

The cacache dependency is written using CJS modules with a dynamic import in one of its dependencies. So, bundling the final PureScript code using esbuild and running the result of that fails.

rhendric commented 8 months ago

That's surprising! I thought esbuild handled mixed dependencies just fine; pretty sure I've used it for this in the past. Are you invoking esbuild through Spago or separately? Any special arguments?

f-f commented 8 months ago

Oh, if this is only when bundling then declaring the dependency as external should do the trick for esbuild, try with --external:cacache

Spago can pass these through to esbuild, see the config file of spago-bin for an example

JordanMartinez commented 8 months ago

Oh! I think the issue was I was naming the output file with a .mjs extension, which causes Node to run it with ES modules enabled. Dropping that fixes the issue. Also, I don't need to include --external:cacache to fix this problem. Commits that got this to work: https://github.com/JordanMartinez/purs-installer/compare/ed313e558ac051a0ac1bfb94995fb690f5b3dd36..master

JordanMartinez commented 8 months ago

Ok, the setup code for tests has been added (based on the ones in Spago). I'll work on that more later.

JordanMartinez commented 7 months ago

I've ported this to PureScipt. One can run it via npm i purs-installer and npx purs-installer install --purs-version 0.15.14. However, see the repo's issues for features not yet implemented.

f-f commented 7 months ago

Should we merge that into here?