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

[Bug?]: Error using ~ alias from package #1632

Open
2 tasks done
oscartbeaumont opened this issue Sep 24, 2024 · 2 comments
Open
2 tasks done

[Bug?]: Error using ~ alias from package #1632

oscartbeaumont opened this issue Sep 24, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@oscartbeaumont
Copy link
Contributor

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

If you use the Typescript import alias ~ from within a package it resolves incorrectly throwing an error.

For context I am also using the vite-tsconfig-paths plugin which correctly handles this situation on a regular Vite app.

You can reproduce the behaviour by running this Solid Start app.

You will seeing the following error in the browser:

[plugin:vite:import-analysis] Failed to resolve import "~/demo" from "lib/src/index.ts". Does the file exist?
/Users/oscar/Desktop/solid-project/lib/src/index.ts:2:7
import "~/demo";

Expected behavior 🤔

No response

Steps to reproduce 🕹

Repository or Stackblitz

Context 🔦

I am fairly sure the fact that Solid Start defines a resolver for ~ which points to the app root is causing the code within the subpackages to try and resolve the alias relative to the root of the app and not the current package.

This can kinda be confirmed by enabling this pnpm patch which removes that resolver and noticing that the error goes away.

Your environment 🌎

No response

@oscartbeaumont oscartbeaumont added the bug Something isn't working label Sep 24, 2024
@ryansolid
Copy link
Member

Hmm.. so it doesn't sound like there is a reasonable solution at the moment. Vite plugin I'm gathering doesn't work because we use 3 vite builds in Vinxi to create the separate module graph needed. Otherwise that would have been the solution here. Having alias at the app level is a SolidStart feature and libraries depending on this you'd hope not have this issue with their output types but if they do then it seems messy regardless.

@AlexErrant
Copy link
Contributor

FWIW, Turborepo recommends multipackage repos to "Use Node.js subpath imports instead of TypeScript compiler paths". I've no experience with Node.js subpath imports, so cannot comment further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants