From 308307e1b1b940d77f770daea5aa4b10e595a667 Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Tue, 23 Jul 2024 14:42:03 -0700 Subject: [PATCH] feat(bundle-source): Entrain devDependencies with development condition --- packages/bundle-source/NEWS.md | 2 ++ packages/bundle-source/README.md | 13 +++++++++++++ packages/bundle-source/src/main.js | 1 + 3 files changed, 16 insertions(+) diff --git a/packages/bundle-source/NEWS.md b/packages/bundle-source/NEWS.md index f86e77ebef..dfe7a7cc33 100644 --- a/packages/bundle-source/NEWS.md +++ b/packages/bundle-source/NEWS.md @@ -13,6 +13,8 @@ - Adds a no-cache, bundle-to-stdout mode. - Adds a `-C,--condition` command flag to specify export/import conditions like `"development"` or `"browser"`. +- The `-C development` condition now provides access to `devDependencies` in + the `package.json` of the entry package of a bundle. # v3.2.1 (2024-03-20) diff --git a/packages/bundle-source/README.md b/packages/bundle-source/README.md index 655dfa83c2..766b94f9e2 100644 --- a/packages/bundle-source/README.md +++ b/packages/bundle-source/README.md @@ -29,6 +29,19 @@ by the `moduleFormat` below. The resulting bundle is suitable for use with `@endo/import-bundle`. The default format is of a bundle is `"endoZipBase64"`. +## Conditions + +Node.js introduced [conditions](https://nodejs.org/api/packages.html#conditional-exports). +The `--condition` and `-C` flags accordingly influence `bundle-source` module +resolution decisions. + +The `browser` condition additionally implies the selection of the `browser` +entry instead of `main` in `package.json`, if not overridden by explicit +`exports`. + +The `development` condition additionally implies that the bundle may import +`devDependencies` from the package containing the entry module. + ## Source maps With the `moduleFormat` of `endoZipBase64`, the bundler can generate source diff --git a/packages/bundle-source/src/main.js b/packages/bundle-source/src/main.js index 11bdd02c0e..c8b54a7205 100644 --- a/packages/bundle-source/src/main.js +++ b/packages/bundle-source/src/main.js @@ -12,6 +12,7 @@ bundle-source [-Tft] bundle-source [-Tft] --cache-js|--cache-json ( )* -f,--format endoZipBase64*|nestedEvaluate|getExport -C,--condition (browser, node, development, &c) + -C development (to access devDependencies) -T,--no-transforms`; const options = /** @type {const} */ ({