mittwald / mittwald/api-client-js

Generator: Incorrect File Extension in Imports for Generated Client

Open
#109 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
2
Forks
0
Avg merge
4d 16h
Merged PRs (30d)
4

Description

Problem Description

The generated client currently includes .js file extensions in the imports of local files like the descriptors.js and types.js. This causes issues with frameworks like Next.js, which do not handle these imports correctly. As a result, users are forced to manually remove the .js extension from these imports.

Steps to Reproduce
  1. Generate the client using the provided tool.
  2. Notice that the imports of local files in the generated code include .js extensions.
  3. Attempt to use the generated client in a Next.js project.
  4. Observe the errors related to import paths with .js extensions.
Example

Here is an example of the problematic import statement:

import * as descriptors from "./descriptors.js";

This needs to be manually corrected to:

import * as descriptors from "./descriptors";
Proposed Solution

Update the client generation logic to omit the .js file extension in the imports of local files. This change should ensure compatibility with frameworks like Next.js and improve the overall usability of the generated client.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the client generation logic used by the provided tool and inspect how local imports such as descriptors.js and types.js are emitted. Reproduce the generated client, then verify that local imports omit the .js extension and work in a Next.js project.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.