ES6 imports breaking client in Expo
- Dominant language
- C#
- Stars
- 3.8k
- Forks
- 333
- Avg merge
- 16h 29m
- Merged PRs (30d)
- 116
Description
### What are you generating using Kiota, clients or plugins?
API Client/SDK
### In what context or format are you using Kiota?
Nuget tool
### Client library/SDK language
TypeScript
### Describe the bug
Relative Imports now include a "index.js" suffix which seems to be causing issues when bundling in React native/expo.
Possible related issue #4950
```ts
Imports are currently generated as
// @ts-ignore
import { DocumentsRequestBuilderNavigationMetadata, type DocumentsRequestBuilder } from './documents/index.js';
// @ts-ignore
import { ProfilesRequestBuilderNavigationMetadata, ProfilesRequestBuilderRequestsMetadata, type ProfilesRequestBuilder } from './profiles/index.js';
// @ts-ignore
import { ThreadsRequestBuilderNavigationMetadata, type ThreadsRequestBuilder } from './threads/index.js';
```
Example error message by Expo
```
Android Bundling failed 63ms C:\Users\[REDACTED]\node_modules\expo-router\entry.js (1 module)
Unable to resolve "../../../models/index.js" from "lib\api\v1\auth\register\index.ts"
```
### Expected behavior
Imports should be generated as
```ts
// @ts-ignore
import { DocumentsRequestBuilderNavigationMetadata, type DocumentsRequestBuilder } from './documents';
// @ts-ignore
import { ProfilesRequestBuilderNavigationMetadata, ProfilesRequestBuilderRequestsMetadata, type ProfilesRequestBuilder } from './profiles';
// @ts-ignore
import { ThreadsRequestBuilderNavigationMetadata, type ThreadsRequestBuilder } from './threads';
```
Or provide an additional flag to override the default behaviour.
### How to reproduce
Generate any typescript client with `kiota generate`
### Open API description file
_No response_
### Kiota Version
1.18.0+5c6b5d0ef23865ba2f9d9f0b9fe4b944cf26b1ec
### Latest Kiota version known to work for scenario above?(Not required)
1.15
### Known Workarounds
- Search and replace to remove "/index.js".
- Downgrade to version 1.15
### Configuration
_No response_
### Debug output
Click to expand log
```
```
### Other information
This is most likely due to #4815
Contributor guide
Research direction
Reproduce the problem by generating a TypeScript client with `kiota generate`, then inspect the generated relative imports and compare bundling behavior in React Native/Expo. Done means the generated client bundles without the `/index.js` resolution error, either by omitting that suffix or by supporting the requested override flag.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, typescript
- Domain
- mobile, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100