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

Feature: Don't check version if path is present #73

Merged
merged 9 commits into from
Aug 7, 2024

Conversation

Gigitsu
Copy link
Contributor

@Gigitsu Gigitsu commented Jul 25, 2024

I think checking the existence of the version param is redundant when using a path for esbuild binary. In this case, esbuild is probably managed with an external package manager (eg. npm).

@josevalim
Copy link
Member

I think we should check the version still, because you want to guarantee all coworkers use the correct one. We would accept a way of setting the version to nil or false, but it may already be supported.

@Gigitsu
Copy link
Contributor Author

Gigitsu commented Jul 25, 2024

It doesn't support setting the version to nil or false.

However, I think I wrote the description wrong because if you set the version, it is still checked. This PR enables you to omit or set the version to nil or false if there is a path, without complaining. But it will still check the version if it is set.

lib/esbuild.ex Outdated
@@ -65,7 +65,7 @@ defmodule Esbuild do

@doc false
def start(_, _) do
unless Application.get_env(:esbuild, :version) do
unless Application.get_env(:esbuild, :version) or Application.get_env(:esbuild, :path) do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think or will work here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, fixed

@josevalim
Copy link
Member

I am worried this will be a breaking change and I also believe the code does not work as you expect. I do t think we should change configured_version() to return anything else other than the configured version.

@Gigitsu
Copy link
Contributor Author

Gigitsu commented Jul 25, 2024

I've fixed the code, sorry about that.

I am worried this will be a breaking change

I thought about it, and I can't see any breaking changes except the lack of a warning log (which is what I want to achieve with this PR). Without these changes, if you don't set a version, you always get a warning. Now you get a warning only if you don't set a path as well.

The other difference is the default version printed in the warning log. But, in my opinion, if you set the path and a version, it's correct that the default version is the bin one.

There is no changes in the behaviour of the library as far as I can tell, unless I'm missing something :D

@josevalim
Copy link
Member

But, in my opinion, if you set the path and a version, it's correct that the default version is the bin one.

That's breaking change. Now someone can update the version and a co-worker will still use the old version. As I said, we can have an option to explicitly disable the check, but I don't think we should change the return value of configured_version.

@Gigitsu
Copy link
Contributor Author

Gigitsu commented Jul 25, 2024

Now someone can update the version and a co-worker will still use the old version.

There's probably something I'm missing, but when can this happen?

There are 3 scenarios, as far as I can tell:

  1. You don't set either :version or :path -> it behaves as before
  2. You set only :path -> no warnings are printed (this is what this PR aims to achieve)
  3. You set both :version and :path -> if the version you set differs from the version of the installed bin, you get a warning like before.

I thought you were concerned about point 3. but in that case, it behaves as before.

The value returned by configured_version() changes only in scenario 2. when you set :path and don't set :version.

@Gigitsu
Copy link
Contributor Author

Gigitsu commented Jul 25, 2024

But I can see why you wouldn't want to change the behaviour of configured_version.

With my code it doesn't return the "configured" version anymore but something more like a "target" or "desired" version.

What do you think about changing the name of that function?

@Gigitsu
Copy link
Contributor Author

Gigitsu commented Aug 7, 2024

Hi @josevalim, can I do something to improve this PR?

@josevalim
Copy link
Member

This comment is still relevant: #73 (comment)

@Gigitsu
Copy link
Contributor Author

Gigitsu commented Aug 7, 2024

Ok so I'll try to add an option to explicitly disable the check. Could version_check: true | false work for you?

@Gigitsu
Copy link
Contributor Author

Gigitsu commented Aug 7, 2024

PR updated. I want to add a test but I don't know how to do it. I thought to download an older version, and then run the esbuild process capturing the output, but I'm not sure this is the right approach.

@josevalim
Copy link
Member

Please update the docs here and we should be good to go: https://github.com/phoenixframework/esbuild/blob/main/lib/esbuild.ex#L22

@Gigitsu
Copy link
Contributor Author

Gigitsu commented Aug 7, 2024

Updated

lib/esbuild.ex Outdated Show resolved Hide resolved
Co-authored-by: José Valim <jose.valim@gmail.com>
@josevalim josevalim merged commit ac23b69 into phoenixframework:main Aug 7, 2024
2 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@Gigitsu Gigitsu deleted the hotfix/version-wiht-path branch August 7, 2024 14:24
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.

2 participants