DavidWells / DavidWells/analytics
Split client & serverside imports
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 267
- PR merge metrics
- No merged PRs in 30d
Description
Currently imports work with a single simple import statement, e.g.
import googleAnalytics from '@analytics/google-analytics'
This is great for dev ergonomics but causes issues with typescript because the serverside code can have different types than the client code 😅. Bummer! Reference issue in TS repo
So it appears we need a different approach to this.
It will most likely look something like this with client and server import paths
// import client side code for browser
import googleAnalytics from '@analytics/google-analytics/client'
// import server side code for node enviroment
import googleAnalytics from '@analytics/google-analytics/server'
Not as pretty but this should solve typescripts inability to resolve the correct type files.
Open to suggestions if anyone has ideas on this 😃
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing how the @analytics/google-analytics package currently exposes its single import and its TypeScript declarations. Compare the client and server type requirements described in the issue, then determine how separate /client and /server imports should resolve. Done means both environment-specific imports resolve with the correct types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100