Skip to content

feat(install): added --prod to skip dev deps and @types#33248

Merged
bartlomieju merged 2 commits into
mainfrom
reland/install-prod-flag
Apr 29, 2026
Merged

feat(install): added --prod to skip dev deps and @types#33248
bartlomieju merged 2 commits into
mainfrom
reland/install-prod-flag

Conversation

@bartlomieju

@bartlomieju bartlomieju commented Apr 12, 2026

Copy link
Copy Markdown
Member

Reland of #32863, which was reverted in #33212 to be relanded for Deno v2.8.


  • Added the --prod flag to deno install that skips devDependencies from package.json.
  • Added the --skip-types flag to deno install, only available with --prod. It makes @types/* packages skipped as well from both package.json and deno.json imports. It may be unsafe to use, as only name.starts_with is used to skip @types/ packages, but such packages not guaranteed to have only types actually.
  • When combined with --entrypoint, the module graph is built as "code only" (excludes type-only dependencies).
  • Conflicts with --global and --dev flags.

Closes #26121
Closes #33181

- Added the `--prod` flag to `deno install` that skips `devDependencies`
from `package.json`.
- Added the `--skip-types` flag to `deno install`, only available with
`--prod`. It makes `@types/*` packages skipped as well from both
`package.json` and `deno.json` imports. It may be unsafe to use, as only
`name.starts_with` is used to skip `@types/` packages, but such packages
not guaranteed to have only types actually.
- When combined with `--entrypoint`, the module graph is built as "code
only" (excludes type-only dependencies).
- Conflicts with `--global` and `--dev` flags.

## How to use

`deno install --prod --skip-types`
`deno install --prod --entrypoint main.ts`

Closes #26121
@bartlomieju bartlomieju modified the milestones: 3.0, 2.8.0 Apr 12, 2026
@bartlomieju bartlomieju changed the title reland: feat(install): added --prod to skip dev deps and @types feat(install): added --prod to skip dev deps and @types Apr 12, 2026

@lunadogbot lunadogbot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM -- traced the production/skip_types plumbing from flags.rs -> InstallTopLevelFlags/InstallEntrypointsFlags -> CliFactory -> NpmInstallerFactoryOptions -> NpmInstallDepsProvider::from_workspace, and verified the actual filter logic at the right place: dev_deps = if production { &empty } else { &deps.dev_dependencies } skips the entire dev tree, and the per-package if skip_types && pkg_req.name.starts_with('@types/') { continue } runs in both the deno.json import path and the package.json dep path. The GraphKind::CodeOnly switch in cli/args/mod.rs:540 for entrypoint+production correctly drops type-only imports from the module graph (the entrypoint_prod_skips_type_only_imports test exercises this). Conflicts (--prod vs --global/--dev, --skip-types requires --prod) are enforced at the clap layer with matching unit tests.

One non-blocking note: the @types/* name-prefix heuristic is acknowledged as risky in the help text, which is the right call -- DefinitelyTyped packages occasionally ship runtime shims (e.g. @types/inquirer historically had module re-exports that some code path actually consumed). Worth a release-note line emphasizing that --skip-types should be paired with a CI run-time check, not blindly used in production Dockerfiles.

@bartlomieju
bartlomieju enabled auto-merge (squash) April 29, 2026 09:43
@bartlomieju
bartlomieju merged commit 59b5848 into main Apr 29, 2026
268 of 270 checks passed
@bartlomieju
bartlomieju deleted the reland/install-prod-flag branch April 29, 2026 11:40
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.

Feature Request: use --prod with auto-install in deno run deno install --prod

3 participants