Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6 imports breaking client in Expo #5485

Open
BrianUribe6 opened this issue Sep 27, 2024 · 2 comments
Open

ES6 imports breaking client in Expo #5485

BrianUribe6 opened this issue Sep 27, 2024 · 2 comments
Labels
Needs: Attention 👋 type:bug A broken experience TypeScript Pull requests that update Javascript code

Comments

@BrianUribe6
Copy link

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

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-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 ```
</details>


### Other information

This is most likely due to  #4815 
@BrianUribe6 BrianUribe6 added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Sep 27, 2024
@msgraph-bot msgraph-bot bot added the TypeScript Pull requests that update Javascript code label Sep 27, 2024
@andrueastman
Copy link
Member

Thanks for raising this @BrianUribe6

To confirm, any chance you've updated your project to use the config as outlined at this link?
https://learn.microsoft.com/en-us/openapi/kiota/quickstarts/typescript#project-configuration

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Oct 1, 2024
@BrianUribe6
Copy link
Author

Yes, some of the settings are already defined in "expo/tsconfig.base", but to make sure I included them again. I'd like to re-emphasize that by completely removing "/index" from every import the client works as expected even with expo's default tsconfig.

tsconfig.json

{
	"extends": "expo/tsconfig.base",
	"compilerOptions": {
		"strict": true,
		"paths": {
			"@/*": ["./*"]
		},
		"lib": ["DOM", "ESNext", "ES2015"],
		"esModuleInterop": true,
		"forceConsistentCasingInFileNames": true,
		"moduleResolution": "NodeNext",
		"module": "NodeNext"
	},
	"include": ["**/*.ts", "**/*.tsx", ".expo/types/**/*.ts", "expo-env.d.ts"]
}

expo/tsconfig.base

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "display": "Expo",

  "compilerOptions": {
    "allowJs": true,
    "esModuleInterop": true,
    "jsx": "react-native",
    "lib": ["DOM", "ESNext"],
    "moduleResolution": "node",
    "noEmit": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "target": "ESNext"
  },

  "exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"]
}

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Attention 👋 type:bug A broken experience TypeScript Pull requests that update Javascript code
Projects
Status: Waits for author 🔁
Development

No branches or pull requests

2 participants