Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support configuration via an external script #14

Closed
wants to merge 1 commit into from
Closed

Support configuration via an external script #14

wants to merge 1 commit into from

Conversation

joeyates
Copy link

The esbuild project has no plans
to accept plugin configuration via the CLI.

As the current implementation only accepts command-line arguments via args,
Phoenix projects would be precluded from the use of any plugins.

This commit provides an alternative to the args profile parameter: script,
which is the name of a Javascript build script and so allows devs to access
the full range of configuration options offered by the JS API.

The esbuild project has [no plans](evanw/esbuild#884 (comment))
to accept plugin configuration via the CLI.

As the current implementation only accepts command-line arguments via `args`,
Phoenix projects would be precluded from the use of any plugins.

This commit provides an alternative to the `args` profile parameter: `script`,
which is the name of a Javascript build script and so allows devs to access
the full range of configuration options offered by the JS API.
@mcrumm
Copy link
Member

mcrumm commented Aug 14, 2021

Hi @joeyates, thanks for the PR. The purpose of this esbuild package is to be able to avoid the pain experienced by new devs that comes about when needing to install node/npm/webpack on an Elixir app.

The JS API, and subsequently the plugin interface, are only available via the node-based version of esbuild. At the very least, more information would need to be provided on the docs to explain the node dependency when using the script option. That said, we are unlikely to expose this option due to the aforementioned pain caused by node/npm.

Others should weigh in in case I am completely off base :)

@joeyates
Copy link
Author

Hi @mcrumm,

While I understand the desire for an alternative to the pain caused by webpack et al, I think that using (Elixir Phoenix's) esbuild in the current form is problematic in the long run.

Without plugins, my impression is that applications will be easy to create, but as soon as devs start wanting to use anything beyond the basics (e.g. SASS), they will be faced with the choice of migration to another build system, or even the use of a combination of esbuild plus another system.

This would mean that Phoenix applications risk becoming more complicated if the only esbuild configuration method available to Phoenix devs is what is exposed by the CLI.

@mcrumm
Copy link
Member

mcrumm commented Aug 14, 2021

If you must install node/npm already to use esbuild plugins, then you don't need this package– you can configure a node watcher for Phoenix that points to your esbuild script :)

@josevalim
Copy link
Member

I agree with @mcrumm that you don't need this project if you want to use the JS API but I also agree with @joeyates that we currently don't provide any migration path for those who want to opt-in to the node stuff.

@joeyates, would you be so kind to provide a small document, it can be a section in the README or in the Esbuild module docs, that outline the steps to move to node-based esbuild? I think it will require four steps:

  1. Run npm install --save-dev esbuild ...
  2. Create a assets/escript.js file
  3. Change config/dev.exs to call node ... --watch instead of Esbuild.install_and_watch under the watchers key
  4. Remove esbuild from mix.exs

Thank you! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants