From 1750ff886503b3c07e30e7e7d22e70eb9a303e10 Mon Sep 17 00:00:00 2001 From: Cristiano Belloni Date: Tue, 28 Jun 2022 16:29:15 +0100 Subject: [PATCH] PR comments --- docs/esm-views/known-limitations.md | 17 ++++++++++++++++- .../src/utils/getPackageDependencies.ts | 1 - 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/esm-views/known-limitations.md b/docs/esm-views/known-limitations.md index 0fb79e26e..acf5f42e2 100644 --- a/docs/esm-views/known-limitations.md +++ b/docs/esm-views/known-limitations.md @@ -92,4 +92,19 @@ would lock React to the same version throught the whole dependency tree on the CDN). [It also provides `[selectiveCDNResolutions]`](./esm-cdn.md), a template string to automatically translate [Yarn selective version resolutions](https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/) -to lists of locked dependencies. +to lists of locked dependencies. For example, if you had these resolutions in +your package.json: + +```json +{ + "resolutions": { + "react": "17.0.1", + "another-dependency": "2.3.7" + } +} +``` + +and your environment contained +`EXTERNAL_CDN_TEMPLATE="https://esm.sh/[name]@[resolution]?deps=[selectiveCDNResolutions]`, +all your imports would be rewritten in this form: +`import someDependency from "https://esm.sh/some-dependency@7.7.7?deps=react@17.0.1,another-dependency@2.3.7"` diff --git a/packages/modular-scripts/src/utils/getPackageDependencies.ts b/packages/modular-scripts/src/utils/getPackageDependencies.ts index ec61741f1..a89bddd99 100644 --- a/packages/modular-scripts/src/utils/getPackageDependencies.ts +++ b/packages/modular-scripts/src/utils/getPackageDependencies.ts @@ -78,7 +78,6 @@ export async function getPackageDependencies(target: string): Promise<{ // Some CDNs support this mechanism - https://github.com/esm-dev/esm.sh#specify-external-dependencies // This is especially useful if we have stateful dependencies (like React) that we need to query the same version through all our CDN depenencies // We just output them as a comma-separated parameter in the CDN template as [selectiveCDNResolutions] - // TODO: possibly fallback to a filtered version of resolutions if this is not present const selectiveCDNResolutions = targetManifest?.resolutions ?? {}; // Package dependencies can be either local to the package or in the root package (hoisted)