Working with linked packages
- Dominant language
- JavaScript
- Stars
- 5.3k
- Forks
- 187
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I hit into one little snag when setting it up. We have split our app into private npm packages and in development we are running everything with symlinks (`npm link`).
Given that this package uses module scope (https://github.com/Khan/aphrodite/blob/master/src/inject.js#L105), it's not possible to have multiple dependency declarations of this package as the module variables are cached separately.
For example if there is a generic server package and a project package, with both declaring `aphrodite` in `package.json` the `inject.js` modules will differ, running into `Cannot automatically buffer without a document` flow and causing the server to crash.
In production the dependency tree is deduped and there is one instance of the `aphrodite` package.
One possible option would be to break variables out of module scope into `global/window`.
I wonder if fixing this would be in the scope of the project?
We have a workaround of importing aphrodite through common utility package to prevent duplicates.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at src/inject.js around line 105 and reproduce the duplicate-package setup described with npm link, including separate server and project declarations. Trace the module-scoped state that leads to “Cannot automatically buffer without a document.” Done means the linked development setup no longer crashes when both packages depend on aphrodite, with behavior verified against the reported scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100