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

Add JSDoc for all configuration options as webpack #4241

Open
chenjiahan opened this issue Sep 25, 2023 · 19 comments
Open

Add JSDoc for all configuration options as webpack #4241

chenjiahan opened this issue Sep 25, 2023 · 19 comments
Assignees
Labels
feat New feature or request team The issue/pr is created by the member of Rspack. to be discussed Rspack team would discuss these issues per week
Milestone

Comments

@chenjiahan
Copy link
Member

What problem does this feature solve?

Can we add JSDoc for all configuration options as webpack?

  • webpack:
Screenshot 2023-09-25 at 11 03 39
  • Rspack:

image

What does the proposed API of configuration look like?

Same as webpack:

image

@chenjiahan chenjiahan added feat New feature or request pending triage The issue/PR is currently untouched. labels Sep 25, 2023
@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Sep 25, 2023
@hyf0
Copy link
Collaborator

hyf0 commented Sep 25, 2023

The type of rspack options is inferred by zod. It's not possible in the current time. See colinhacks/zod#200 (comment) for details.

@hyf0 hyf0 removed the pending triage The issue/PR is currently untouched. label Sep 25, 2023
@chenjiahan
Copy link
Member Author

It seems that JSDoc can work in some cases:

image

colinhacks/zod#200 (comment)

@dinckelman
Copy link

This appears to be very much situational, because as shown below, VSCode cannot detect the comment, and Webstorm is... well, trying to do something else entirely
Screenshot 2023-10-14 at 23 21 57
Screenshot 2023-10-14 at 23 21 32

@hardfist hardfist added the to be discussed Rspack team would discuss these issues per week label Oct 15, 2023
@hardfist
Copy link
Contributor

it indeed hurt DX for users,we will try to find better ways to do this

Copy link

stale bot commented Dec 14, 2023

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@stale stale bot added the stale label Dec 14, 2023
@chenjiahan
Copy link
Member Author

bump

@stale stale bot removed the stale label Dec 14, 2023
Copy link

stale bot commented Feb 12, 2024

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@stale stale bot added the stale label Feb 12, 2024
@xc2
Copy link
Collaborator

xc2 commented Feb 12, 2024

bump

@stale stale bot removed the stale label Feb 12, 2024
Copy link

stale bot commented Apr 13, 2024

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@stale stale bot added the stale label Apr 13, 2024
@chenjiahan
Copy link
Member Author

bump

@stale stale bot removed the stale label Apr 13, 2024
Copy link

stale bot commented Jun 12, 2024

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@stale stale bot added the stale label Jun 12, 2024
@chenjiahan
Copy link
Member Author

bump

@stale stale bot removed the stale label Jun 12, 2024
Copy link

stale bot commented Aug 11, 2024

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@stale stale bot added the stale label Aug 11, 2024
@hardfist hardfist removed the stale label Sep 5, 2024
@hardfist
Copy link
Contributor

hardfist commented Sep 5, 2024

the zod type definition is too complex to maintain and read in d.ts, we may consider go back to handwritten json schema with comment support

@hardfist hardfist added this to the 1.1.0 milestone Sep 5, 2024
@chenjiahan
Copy link
Member Author

@hardfist handwritten json schema or handwritten config types?

@ecraig12345
Copy link

In addition to the missing documentation, it's extremely hard to understand the generated zod types when looking at the .d.ts or intellisense in an editor. And it seems like TS can't always infer the types of functions in complex union types--I filed a bug #7979 for externals functions specifically.

@GiveMe-A-Name
Copy link
Member

I have some ideas about this.

  1. One is using json schema, like webpack. It means we need maintain a json schema.
  2. Another one is that maintain another types for UX. Like the code bellow:
interface Address {
    id?: string
    addressText: string
    line1: string
    line2?: string
    city: string
    state: string
    postalCode: string
    country: string
}

const addressSchema = z.object( {
    id: z.string().optional(),
    addressText: z.string(),
    line1: z.string(),
    line2: z.string().optional(),
    city: z.string(),
    state: z.string(),
    postalCode: z.string(),
    country: z.string(),
} ) satisfies z.ZodType<Address>

see colinhacks/zod#1870 more detail.

Actually, if we can transform ts to zod or zod to ts, it's a better way. But Rspack Configuration types is so complex, ts-to-zod can't transform it correctly.
see colinhacks/zod#779 more transform way.

So I prefer second way. But the drawback is we need maintain a another types.

@chenjiahan
Copy link
Member Author

The second one LGTM 👍 If we take this approach, we can incrementally migrate types and add JSDoc comments.

@GiveMe-A-Name
Copy link
Member

GiveMe-A-Name commented Sep 27, 2024

Tasks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request team The issue/pr is created by the member of Rspack. to be discussed Rspack team would discuss these issues per week
Projects
None yet
Development

No branches or pull requests

7 participants