feat(install): added --prod to skip dev deps and @types#33248
feat(install): added --prod to skip dev deps and @types#33248bartlomieju wants to merge 1 commit intomainfrom
Conversation
- 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
lunadogbot
left a comment
There was a problem hiding this comment.
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.
Reland of #32863, which was reverted in #33212 to be relanded for Deno v2.8.
--prodflag todeno installthat skipsdevDependenciesfrompackage.json.--skip-typesflag todeno install, only available with--prod. It makes@types/*packages skipped as well from bothpackage.jsonanddeno.jsonimports. It may be unsafe to use, as onlyname.starts_withis used to skip@types/packages, but such packages not guaranteed to have only types actually.--entrypoint, the module graph is built as "code only" (excludes type-only dependencies).--globaland--devflags.Closes #26121
Closes #33181