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

Add yarn:add command to add NPM package #72

Closed
wants to merge 1 commit into from

Conversation

saiqulhaq
Copy link
Contributor

@saiqulhaq saiqulhaq commented Oct 28, 2023

Do you think the readme file update is correct?

@nickjj
Copy link
Owner

nickjj commented Oct 28, 2023

Hi,

Normally to add a new dependency I'd add the package to package.json and then run ./run yarn:install. That will ensure the following:

  • The new package is referenced
  • A new Docker image gets built
  • A new yarn.lock file gets volume mounted out so you can commit it

Are you using a different workflow?

@saiqulhaq
Copy link
Contributor Author

adding a new package to package.json file means I have to know what is the latest version
yarn add xxx will install the latest version
which is a common workflow, where we normally install the latest version
yarn add is the same as bundle add

@nickjj
Copy link
Owner

nickjj commented Oct 28, 2023

If you make a change to the running container with add and then stop the container, do you have re-run ./run yarn:install before the next time you start the container? Otherwise you would lose whatever was installed in the image since it was adjusted at runtime in the previously running container.

I think I'd prefer having a shortcut for ./run yarn <...> where you can run anything. The only reason yarn:install exists is because it does a few other things besides installing to ensure the lock file gets written out.

@saiqulhaq
Copy link
Contributor Author

I don't need to run yarn:install command, since yarn:add will update the package.json and yarn.lock files.
so in the next run, docker compose up --build will automatically install the dependencies during the image building process. the new running container should able to run without any issue.
if using _build_run_down command, it would take a very long time to just add a single NPM package.

I am not sure about another yarn's command. I worry that the command affects the current running container only.

@nickjj
Copy link
Owner

nickjj commented Oct 28, 2023

Right, but the takeaway there is you need to run up --build or build after add so you end up having to wait some time for that.

@saiqulhaq
Copy link
Contributor Author

oh ok, then let me close this PR
since it's not suitable for everyone
I always run up --build in my development workflow
thanks a lot for the feedback

@saiqulhaq saiqulhaq closed this Oct 28, 2023
@saiqulhaq saiqulhaq deleted the patch-2 branch October 28, 2023 23:51
@nickjj
Copy link
Owner

nickjj commented Oct 29, 2023

No problem. Thanks for opening this tho!

@lesterzone
Copy link

I came here for this ...means I have to know what is the latest version yarn add xxx will install the latest version

I just added a new run command:

function yarn:add {
  # Add dependencies to our package.json
  _build_run_down js yarn add "${1}"
}

Just because I want to add the dependency with the version to package.json

@nickjj
Copy link
Owner

nickjj commented Nov 10, 2023

Yep that works. Also for keeping things up to date you can run ./run yarn:outdated to get a list of outdated dependencies. Likewise bundle:outdated exists too.

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