phoenixframework / esbuild

An installer for esbuild
MIT License
269 stars 36 forks source link

chg: configuarable installation of esbuild #28

Closed philippseith closed 2 years ago

philippseith commented 2 years ago

The config key :installmode controls how the esbuild executable is downloaded and installed.

By using an existing npm installation, the problems mentioned in https://github.com/phoenixframework/esbuild/issues/26#issuecomment-929834668 are circumvented. Furthermore, the already working npm configuration, including a custom registry and all its security and authentication settings is used.

josevalim commented 2 years ago

Hi @philippseith! Thanks for the PR but I would prefer to not depend on the precise mechanics of npm install. Based on your PR, I pushed a tiny configuration that allows the path to be configured. In your app, you would be to do this:

config :esbuild,
  path: System.get_env("MIX_ESBUILD_PATH")

Now you can do npm install -g esbuild and make it point precisely to the esbuild path. Please give it a try and let me know!

philippseith commented 2 years ago

Cool, that's much simpler. But: It works on linux but on Windows there are some quirks.

philippseith commented 2 years ago

BTW: The test fails here (both on linux and windows) https://github.com/phoenixframework/esbuild/blob/6c73497492adfa19a513da7145c160bcd59019c6/test/esbuild_test.exs#L21 when the installed version is different to the one required from the test

josevalim commented 2 years ago

@philippseith Yeah, the reason why cmd fails is because where.exe esbuild is not pointing to esbuild, but rather a shim escript that executes esbuild. Pointing to esbuild.exe is the way to go. I have changed the docs in this commit to clarify that: https://github.com/phoenixframework/esbuild/commit/6c73497492adfa19a513da7145c160bcd59019c6