aws / aws/jsii

A bundled dep is required even if public API does not expose types from jsii dep with partial bindings

Open
#2,992 0 comments 0 reactions 0 assignees View on GitHub
bug module/compiler module/jsii p1
Dominant language
TypeScript
Stars
2.9k
Forks
267
Avg merge
1d 25m
Merged PRs (30d)
14

Description

## :bug: Bug Report

### Affected Languages

- [ ] `TypeScript` or `Javascript`
- [x] `Python`
- [x] `Java`
- [x] .NET (`C#`, `F#`, ...)
- [x] `Go`

### General Information
* **JSII Version:** `1.34.0 (build 9b72778), typescript 3.9.10`
* **Platform:** `Darwin Harolds-MBP-193 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64`

### What is the problem?

[Isolated source demonstration of the problem](https://github.com/pwrdrvr/jsii-hidden-deps)

This repository demonstrates a possible issue / design limitation, similar to #2942, in that private modules must provide support for all target languages of the consuming module, else the private module must be listed as a `bundledDependencies`, causing it and all of it's dependencies to be bundled with the new module being created.

The module being consumed, [@cloudcomponents/cdk-deletable-bucket](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-deletable-bucket) has jsii bindings for `js` and `python` only and the library I have created has support for `dotnet` and `java` as well.

It seems that a `jsii` module should be able to privately use other `jsii` modules with partial or missing language bindings so long as no types from that module are exposed in the public api of the new module. If this is possible then the private module should no longer need to be listed in `bundledDependencies` and can be installed at runtime instead.

This seems to be related to, but slightly different than the similar issue, #2942, for private modules needing to be `peerDependencies` even if they are not exposed in the public API.

### Verbose Log

```
npx jsii-pacmak --verbose
[jsii-pacmak] [INFO] Found 1 modules to package
[jsii-pacmak] [INFO] Packaging NPM bundles
[jsii-pacmak] [INFO] Loading jsii assemblies and translations
[jsii-pacmak] [INFO] Packaging 'dotnet' for jsii-hidden-deps
[jsii-pacmak] [INFO] Packaging 'go' for 0 modules
[jsii-pacmak] [INFO] Packaging 'java' for jsii-hidden-deps
[jsii-pacmak] [INFO] Packaging 'js' for jsii-hidden-deps
[jsii-pacmak] [INFO] Packaging 'python' for jsii-hidden-deps
[jsii-pacmak] [INFO] go finished
[jsii-pacmak] [WARN] Exception occurred, not cleaning up
[jsii-pacmak] [WARN] dotnet failed
[jsii-pacmak] [WARN] Exception occurred, not cleaning up
[jsii-pacmak] [WARN] java failed
[jsii-pacmak] [WARN] python failed
TypeError: Cannot read property 'namespace' of undefined
at DotNetTypeResolver.resolveNamespacesDependencies (/Users/huntharo/pwrdrvr/jsii-hidden-deps/node_modules/jsii-pacmak/lib/targets/dotnet/dotnettyperesolver.js:71:46)
at DotNetGenerator.generate (/Users/huntharo/pwrdrvr/jsii-hidden-deps/node_modules/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.js:43:27)
at Dotnet.generateCode (/Users/huntharo/pwrdrvr/jsii-hidden-deps/node_modules/jsii-pacmak/lib/target.js:29:28)
at async DotnetBuilder.generateModuleCode (/Users/huntharo/pwrdrvr/jsii-hidden-deps/node_modules/jsii-pacmak/lib/targets/dotnet.js:94:9)
at async /Users/huntharo/pwrdrvr/jsii-hidden-deps/node_modules/jsii-pacmak/lib/targets/dotnet.js:62:30
at async Function.make (/Users/huntharo/pwrdrvr/jsii-hidden-deps/node_modules/jsii-pacmak/lib/util.js:186:36)
at async DotnetBuilder.buildModules (/Users/huntharo/pwrdrvr/jsii-hidden-deps/node_modules/jsii-pacmak/lib/targets/dotnet.js:35:35)
at async Promise.all (index 0)
at async Object.pacmak (/Users/huntharo/pwrdrvr/jsii-hidden-deps/node_modules/jsii-pacmak/lib/index.js:56:9)
```

Contributor guide

Open the contributing guide

Research direction

Start with the isolated demonstration repository and run `npx jsii-pacmak --verbose`. Read the reported `DotNetTypeResolver.resolveNamespacesDependencies` and related generator paths in the log, then compare behavior across the listed target languages. Done means a private jsii dependency with partial bindings no longer requires bundling when its types are absent from the public API, and packaging succeeds for the consuming module.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.