@@ -495,6 +495,69 @@ deno run --reload my_module.ts
495495deno run --reload=jsr:@std/fs my_module.ts
496496```
497497
498+ ## Development only dependencies
499+
500+ Sometimes dependencies are only needed during development, for example
501+ dependencies of test files or build tools. In Deno, the runtime does not require
502+ you to distinguish between development and production dependencies, as the
503+ [ runtime will only load and install dependencies that are actually used in the
504+ code that is being executed] ( #why-does-deno-not-have-a-devimports-field ) .
505+
506+ However, it can be useful to mark dev dependencies to aid people who are reading
507+ your package. When using ` deno.json ` , the convention is to add a ` // dev `
508+ comment after any "dev only" dependency:
509+
510+ ``` json title="deno.json"
511+ {
512+ "imports" : {
513+ "@std/fs" : " jsr:@std/fs@1" ,
514+ "@std/testing" : " jsr:@std/testing@1" // dev
515+ }
516+ }
517+ ```
518+
519+ When using a ` package.json ` file, dev dependencies can be added to the separate
520+ ` devDependencies ` field:
521+
522+ ``` json title="package.json"
523+ {
524+ "dependencies" : {
525+ "pg" : " npm:pg@^8.0.0"
526+ },
527+ "devDependencies" : {
528+ "prettier" : " ^3"
529+ }
530+ }
531+ ```
532+
533+ ### Why does Deno not have a ` devImports ` field?
534+
535+ To understand why Deno does not separate out dev dependencies in the package
536+ manifest it is important to understand what problem dev dependencies are trying
537+ to solve.
538+
539+ When deploying an application you frequently want to install only the
540+ dependencies that are actually used in the code that is being executed. This
541+ helps speed up startup time and reduce the size of the deployed application.
542+
543+ Historically, this has been done by separating out dev dependencies into a
544+ ` devDependencies ` field in the ` package.json ` . When deploying an application,
545+ the ` devDependencies ` are not installed, and only the dependencies.
546+
547+ This approach has shown to be problematic in practice. It is easy to forget to
548+ move a dependency from ` dependencies ` to ` devDependencies ` when a dependency
549+ moves from being a runtime to a dev dependency. Additionally, some packages that
550+ are semantically "development time" dependencies, like (` @types/* ` ), are often
551+ defined in ` dependencies ` in ` package.json ` files, which means they are
552+ installed for production even though they are not needed.
553+
554+ Because of this, Deno uses a different approach for installing production only
555+ dependencies: when running ` deno install ` , you can pass a ` --entrypoint ` flag
556+ that causes Deno to install only the dependencies that are actually
557+ (transitively) imported by the specified entrypoint file. Because this is
558+ automatic, and works based on the actual code that is being executed, there is
559+ no need to specify development dependencies in a separate field.
560+
498561## Using only cached modules
499562
500563To force Deno to only use modules that have previously been cached, use the
0 commit comments