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 installing only production dependencies #250

Closed
3 tasks done
BorePlusPlus opened this issue Jan 24, 2025 · 3 comments · Fixed by #251
Closed
3 tasks done

Support installing only production dependencies #250

BorePlusPlus opened this issue Jan 24, 2025 · 3 comments · Fixed by #251
Labels
enhancement New feature or request

Comments

@BorePlusPlus
Copy link
Contributor

Clear and concise description of the problem

The supported package managers allow for the installation of only production dependencies. This is usually motivated by a desire for a smaller deployment footprint.

Since ni already supports the "mirror" -D flag for installing only development dependencies, I propose adding the -P flag for installing only production dependencies.

Suggested solution

I suggest adding the -P flag to the ni command, which should instruct agents to install only production dependencies (as defined by the agent). I am happy to provide a PR for it.

Alternative

No response

Additional context

There are two things worth pointing out, and they may both trigger a change in antfu-collective/package-manager-detector.

  • Ideally, I'd like to combine clean install (nci a.k.a. ni --frozen) with -P flag, but that would require a change frozen command in antfu-collective/package-manager-detector to accept a parameter. This is my ultimate motivation for the change.
  • New versions of npm have deprecated --production flag, and will print a warning suggesting using --omit=dev. My current PR uses the new (--omit=dev) flag. If we want to support --production flag for older versions (I believe v6 and prior) of npm that do not support --omit we would need to make a change in antfu-collective/package-manager-detector to support that.

If you're up for making these changes, I'd happily provide PRs for them.

Validations

@BorePlusPlus
Copy link
Contributor Author

I noticed that I am proposing using the same flag (-P) for installing production dependencies as @yamcodes proposes for installing peer dependencies in #248 . We may have to decide which (if any) of the proposals should go ahead with using -P

@yamcodes
Copy link

Great catch, @BorePlusPlus. Perhaps one of our PRs can use -p, and the other one can use -P.

@BorePlusPlus
Copy link
Contributor Author

Oh, that was fast. Thanks for merging.
I'll have a look at adding support for -P together with --frozen (or nci) next.

@yamcodes I guess you'll have to look for an alternative flag since my PR that uses -P has been merged. Sorry, I didn't intend to cut in front.

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

Successfully merging a pull request may close this issue.

2 participants