Skip to content

Commit

Permalink
docs(typescript-restrictions): clarify non-jsii deps (#3995)
Browse files Browse the repository at this point in the history
I spent about a day and a half trying to figure this out, so I thought I'd add a little clarification :)

tl;dr: I'm making a CDK Construct package that also includes a custom lambda handler. That handler takes on a non-jsii dep but I couldn't figure out why JSII kept trying to compile that non-jsii dep until I read 
> The API of the *jsii module* can not expose any type from bundled dependencies, since those types would not be available in other languages.
 
about 20 times. 

---

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
  • Loading branch information
Kayo authored Nov 14, 2023
1 parent 960305f commit e3191e5
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ A *jsii module* can declare dependencies on any other *jsii module* by adding en
`package.json` file. Since most other platforms do not support multiple different versions of the same library to
coexist in the same closure, it is recommended to also declare all such dependencies as `peerDependencies`.

### non-jsii dependencies

Occasionally, a dependency on a *non-jsii module* is useful. Since such dependencies do not have generated bindings in
all the supported languages, they must be bundled with the *jsii module* that depends on them, by adding the library
into the `bundleDependencies` array in `package.json`. The API of the *jsii module* can not expose any type from bundled
dependencies, since those types would not be available in other languages.
into the `bundleDependencies` array in `package.json`.

The API of the *jsii module* can not expose any type from bundled dependencies, since those types would not be available in other languages.
TypeScript files that include a non-jsii dependency (e.g. a lambda handler for an AWS CDK Construct) cannot be exported from the `main`/`types` entry point.

!!! info
For more information on `package.json` file contents, refer to the [npm documentation][package-json].
Expand Down

0 comments on commit e3191e5

Please sign in to comment.