@@ -487,6 +487,45 @@ works as well:
487
487
}
488
488
```
489
489
490
+ ## Exports
491
+
492
+ The ` exports ` field in the ` deno.json ` file allows you to define which paths of
493
+ your package should be publicly accessible. This is particularly useful for
494
+ controlling the API surface of your package and ensuring that only the intended
495
+ parts of your code are exposed to users.
496
+
497
+ ``` jsonc title="deno.json"
498
+ {
499
+ " exports" : " ./src/mod.ts" // A default entry point
500
+ }
501
+ ```
502
+
503
+ You can also define multiple entry points:
504
+
505
+ ``` json title="deno.json"
506
+ {
507
+ "exports" : {
508
+ "./module1" : " ./src/module1.ts" ,
509
+ "./module2" : " ./src/module2.ts" ,
510
+ "." : " ./src/mod.ts" // Default entry point
511
+ }
512
+ }
513
+ ```
514
+
515
+ This configuration will:
516
+
517
+ - expose ` module1 ` and ` module2 ` as entry points for your package,
518
+ - allow importing any file from the ` utils ` directory using a wildcard. This
519
+ means users can import these modules using the specified paths, while other
520
+ files in your package remain private.
521
+
522
+ To use the exports in your code, you can import them like this:
523
+
524
+ ``` ts title="example.ts"
525
+ import * as module_1 from " @example/my-package/module1" ;
526
+ import * as module_2 from " @example/my-package/module2" ;
527
+ ```
528
+
490
529
## An example ` deno.json ` file
491
530
492
531
``` json
0 commit comments