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

Svelte component libraries should use "NodeNext" for moduleResolution, not "bundler" #276

Closed
rsweeneydev opened this issue Jan 13, 2024 · 1 comment · Fixed by #352
Closed
Assignees

Comments

@rsweeneydev
Copy link

rsweeneydev commented Jan 13, 2024

Describe the bug

TypeScript types are not resolved property for several bits-ui (and shadcn svelte) components. For example, the shadcn-svelte DropdownMenuContent component props resolve as the "any" type:

Screenshot 2024-01-13 at 12 00 31 PM

This is caused by missing fully specified import specifiers in several places in bits-ui.

For example, bits/floating/types uses "../../internal" rather than "../../internal/index.js".

To prevent these types of issues, and support the widest range of uses, the authors of TypeScript and SvelteKit recommend that library authors not use moduleResolution "bundler". bits-ui is using moduleResolution "bundlers", so these issues are not detected at build.

Here are the relevant links to the documentation:

To fix this issue, bits-ui should add "module": "NodeNext" to it's tsconfig.json and remove "moduleResolution": "bundler". ("module": "NodeNext" implies "moduleResolution": "NodeNext").

This will identify all the places in the library where import specifiers are invalid for modern node.

Reproduction

  1. Create a new SvelteKit project
  2. Set "module": "NodeNext" in tsconfig.json
  3. Add the dropdown menu shadcn-svelte component

Logs

No response

System Info

System:
    OS: macOS 14.1.2
    CPU: (10) arm64 Apple M1 Max
    Memory: 5.62 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
    pnpm: 8.12.0 - ~/.nvm/versions/node/v18.17.1/bin/pnpm
    bun: 1.0.15 - ~/.bun/bin/bun
  Browsers:
    Chrome: 120.0.6099.216
    Safari: 17.1.2

Severity

annoyance

@rsweeneydev
Copy link
Author

BTW, I'm working on a PR with a fix for this.

@rsweeneydev rsweeneydev changed the title Svelte component libraries should use "NodeNext" for moduleResolution, not bundler Svelte component libraries should use "NodeNext" for moduleResolution, not "bundler" Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant