jsii
jsii copied to clipboard
Compiler fails when package name contains dot
Describe the bug
JSII compiler fails when package.json name contains dot, e.g. @foo/example.jsii-dot-error.
This could be a bug or a known limitation (could not find it in the documentation).
Expected Behavior
JSII Compiler is able to compile even when package name contains dot.
Current Behavior
[2024-10-02T09:25:51.066] [DEBUG] jsii/compiler - Creating or updating /***/tsconfig.json
[2024-10-02T09:25:51.429] [TRACE] jsii/assembler - Processing source file: src/index.ts
[2024-10-02T09:25:51.430] [TRACE] jsii/assembler - Processing interface: .Props
[2024-10-02T09:25:51.431] [TRACE] jsii/assembler - Processing property: @foo/example.jsii-dot-error.Props#name
[2024-10-02T09:25:51.434] [INFO] jsii/assembler - Registering JSII interface: @foo/example.jsii-dot-error.Props
[2024-10-02T09:25:51.435] [TRACE] jsii/assembler - Processing class: .ExampleClass
[2024-10-02T09:25:51.435] [TRACE] jsii/assembler - Processing parameter: props
[2024-10-02T09:25:51.437] [INFO] jsii/assembler - Registering JSII class: @foo/example.jsii-dot-error.ExampleClass
[2024-10-02T09:25:51.437] [ERROR] jsii/compiler - Type model errors prevented the JSII assembly from being created
suggestion JSII2: A "homepage" field should be specified in "package.json"
error JSII9000: Encountered use of module that is not declared in "dependencies" or "peerDependencies": "@foo/example"
Reproduction Steps
- Create a JSII project with package name including a dot:
{
"name": "@foo/example.jsii-dot-error"
}
- Add any exported implementation (interface, class etc.)
- Run
npx jsii --verbose --verbose --verbose error JSII9000: Encountered use of module that is not declared in "dependencies" or "peerDependencies": "@foo/example"
Possible Solution
Looks like some parts of the code do string.split('.') on fqn values, maybe it would be possible to make it more sophisticated and consider the package name more throughly in that case?
OR: Document it as known limitation and maybe additionally raise a more descriptive diagnostic error when reading the package.json.
Additional Information/Context
If there's any workarounds, it would be nice to know.
SDK version used
5.5.4 (build 1378d94), typescript 5.5.4
Environment details (OS name and version, etc.)
Apple M1 Max, macOS 14.6.1