feat: node.js subpath imports#76
Open
dotnize wants to merge 9 commits into
Open
Conversation
✅ Deploy Preview for mugnavo-tanstarter ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following #77, since we already use
#/*for the tsconfig path alias.Switch from TypeScript path aliases to standard built-in Node.js subpath imports, which is now supported in the shadcn CLI.
This implementation is a bit different/hacky though, and may not be the standard or proper usage, so I'm not yet sure if we should proceed with this exact implementation.
This enables "extension guessing", allowing a similar level of DX shortcuts as the TypeScript path aliases we were previously using, without having to specify the extensions or redefine aliases for every folder.
references:
#/nodejs/node#60864discussions about this hacky solution:
Alternative paths
Use the recommended and supported standard that explicitly requires file extensions in imports. Explicit is better than implicit.
{ "imports": { "#/*": "./src/*" }, }Use the setup from shadcn docs. Pre-defined directories and extensions in package.json:
.tsxfor/components, and.tsonly for the rest.{ "imports": { "#components/*": "./src/components/*.tsx", "#lib/*": "./src/lib/*.ts", "#env/*": "./src/hooks/*.ts" } }Feedback is welcome.