Skip to content

Solid: generated component updates library index.ts with wrong extension #1162

Description

@ricrac-hac

Describe the bug
When generating a solid component, the library/src/index.ts gets updated with a .ts instead of a .tsx import

To Reproduce

npx create-nx-workspace --preset=apps solid-test
cd solid-test
npm i @nxext/solid
nx g @nxext/solid:application apps/app-web
nx g @nxext/solid:lib libs/lib-app-web
nx g @nxext/solid:component hello --project lib-app-web
cat libs/lib-app-web/src/index.ts

$ cat libs/lib-app-web/src/index.ts

export {};

export { default as Hello } from './components/hello/Hello.ts';

Expected behavior
libs/lib-app-web/src/index.ts should import Hello or Hello.tsx instead of Hello.ts

Note that using .ts or .tsx causes TS5097: An import path can only end with a .tsx extension when allowImportingTsExtensions is enabled. so if we want to keep with .tsx then we also need to update the tsconfig to allow this.

I expect it'd be better to remove the extension entirely for wider compatibility if built libs need to be used outside of a typescript context. I don't have a lot of experience with this though so maybe someone else can weigh in here.

Additional context
Problem also existed in a pnpm based project. Recreated with npm to remove variables

$ nx --version

Nx Version:
- Local: v20.2.2
- Global: v20.1.4

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions