You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rosetta has a feature to include external packages into its example
compilation dependency tree, so that you can write examples in your
README using packages that depend on the package you're writing the
README for. You couldn't have those dependencies in your actual
dependency tree, but there is a special section in `package.json` that
can do it.
Schematically:
```
mydep
▲
│
mypackage < write a compilable example that uses 'myinteg'
▲
│
myinteg
```
Put the following into `package.json`:
```json
{
"jsiiRosetta": {
"exampleDependencies": {
"myinteg": "^1.2.3"
}
}
}
```
While this feature was advertised, it didn't actually work:
* The dependency closure tree was built, but it was never used during
compilation (we erroneously set the compilation directory to the
directory of the package the sample was found).
* You could not specify `*` as a version number because a package we
use, `semver-intersect`, doesn't support `*`.
* We need to take additional care when mixing symlinked and installed
packages that `peerDependency` (e.g., `constructs`). By the original
closure directory construction method, we would end up with the wrong
version of `aws-cdk-lib` in the dependency closure, and 2 copies of
`constructs` (leading to the `Construct is not assignable to Construct`
error).
To solve all of this, fully crawl the dependency tree, build a
`package.json` to install everything in one go, and do use the
compilation directory that we build this way.
Also in this PR:
* Wrap `semver-intersect` with a helper function to handle one more case
and fail gracefully if we encounter more cases it doesn't handle.
* Add some debug printing and a `--no-cleanup` flag for easier
debugging.
---
By submitting this pull request, I confirm that my contribution is made
under the terms of the [Apache 2.0 license].
[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
---------
Signed-off-by: github-actions <[email protected]>
Co-authored-by: github-actions <[email protected]>
0 commit comments