Compiler fails when package name contains dot
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 267
- Avg merge
- 1d 25m
- Merged PRs (30d)
- 14
Description
### 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
1. Create a JSII project with package name including a dot:
```json
{
"name": "@foo/example.jsii-dot-error"
}
```
2. Add any exported implementation (interface, class etc.)
3. Run `npx jsii --verbose --verbose --verbose`
4. `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
Contributor guide
Research direction
Start with the reproduced package.json name and run npx jsii --verbose --verbose --verbose to confirm the JSII9000 diagnostic. Trace the FQN handling mentioned in the report, especially places that split on '.', and verify the compiler accepts the dotted package name without treating it as the undeclared @foo/example dependency.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100