Description
What package is covered by this investigations?
A private package under the @elastic
scope and @elastic/elasticsearch
, the Elasticsearch Javascript library.
@elastic/x
private package is published to GitHub's npm package manager.@elastic/elasticsearch
is public and published to npm (https://www.npmjs.com/package/@elastic/elasticsearch).
Describe the goal of the investigation
Determine how to use one scope with multiple registries like most other build systems.
Investigation report
The problem stems from this line in the npm documentation for registries, which also appears to apply to Yarn, although I could not find it explicitly in Yarn's documentation:
https://docs.npmjs.com/misc/scope#associating-a-scope-with-a-registry
Scopes have a many-to-one relationship with registries: one registry can host multiple scopes, but a scope only ever points to one registry.
(Emphasis mine)
As a high level goal, this approach makes a lot of sense: simplify the lookup process and thus guarantee that once found, it will most likely always be there or error out. However, for complex, internal projects it really breaks down. Internal projects tend to have internal dependencies that will often benefit from public dependencies from the same organization (aka scope).
In other build systems, like Gradle, a series of registries can be defined and the first hit -- when executed in order -- will be used for any given dependency. This is not only helpful, but it seems necessary in the growing world of npm usage where GitHub is now offering a mechanism for private publication alongside npmjs.com (which is perhaps confusing given that GitHub recently acquired npm).