Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristiano Belloni committed Jun 28, 2022
1 parent 46d7a37 commit 1750ff8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 16 additions & 1 deletion docs/esm-views/known-limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1750ff8

Please sign in to comment.