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

Unable to add/update TS path alias in tsconfig.json #393

Closed
dallastjames opened this issue Nov 1, 2022 · 4 comments
Closed

Unable to add/update TS path alias in tsconfig.json #393

dallastjames opened this issue Nov 1, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@dallastjames
Copy link

In a new project, it doesn't appear possible to add or change the paths defined in the tsconfig.json file.

Simple Repro

I spun up a blank project using pnpm (pn create solid -> blank) and verified that it ran correctly. Then changed the ts config path that comes predefined from ~/* to @/*, updating the references in the project accordingly. Then running dev, the following error is returned in the console:

An unhandler error occured: Error: Cannot find module '@/components/Counter' imported from '/Projects/Personal/solid-tsconfig-check/src/routes/index.tsx'

From some additional testing, it seems like the ~/* reference is likely overriding whatever is in the typescript config file in the project. That path alias remains valid even after changing it.

Being new to Solid and Solid-Start, I'm unsure if this path is just built in to Solid and to use any other custom ones requires use of a vite plugin, or if this is a build error with Solid Start.

Thanks!

@nksaraf
Copy link
Member

nksaraf commented Nov 1, 2022

Yeah I think this might be an issue with the expectation. We currently don't support the tsconfig paths directly. We use ~/ as an alias for src/*. For adding more aliases, you would need to define in both tsconfig and vite config's resolve.alias option.

But I do understand that it'll be better if we supported the tsconfig paths directly. There is a vite plugin that does this: https://www.npmjs.com/package/vite-tsconfig-paths.. You can try this until we include it with the solidstart preset

@nksaraf nksaraf closed this as completed Nov 1, 2022
@nksaraf nksaraf reopened this Nov 1, 2022
@dallastjames
Copy link
Author

Ok, perfect. I had a suspicion that was likely the case just by how it was behaving and seemingly unresponsive to any changes made in the tsconfig paths. The vite plugin you mentioned was something I'd considered using, but didn't want to go down that path if I was just missing something else.

Thanks for the answer!

@nksaraf
Copy link
Member

nksaraf commented Nov 2, 2022

If we implement this itll probaly be using that plugin. So you can use it directly right now to support tsconfig paths

@ryansolid ryansolid added the enhancement New feature or request label Dec 21, 2022
@ryansolid
Copy link
Member

In setting up for SolidStarts next Beta Phase built on Nitro and Vinxi we are closing all PRs/Issues that will not be merged due to the system changing. If you feel your issue was closed in mistake. Feel free to re-open it after updating/testing against 0.4.x release. Thank you for your patience.

See #1139 for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants