Scope package dependencies are not linked during oc package
Taiters opened this issue · 1 comments
Who is the bug affecting?
Component creators when packaging components (In our case, this was observed in a CI pipeline)
What is affected by this bug?
oc cli
When does this occur?
When packaging components with --useComponentDependencies
Where on the platform does it happen?
cli
How do we replicate the issue?
In our case, our CI pipeline which packages OCs will run oc package --useComponentDirectories /path/to/project
. The working directory already has a node_modules
folder, so when this command runs, the project's dependencies which are not already in this folder should be added as symlinks.
To recreate:
- Create a component which has a scoped dependency, such as
@babel/core
- From a different directory, which contains a
node_modules
folder, runoc package --useComponentDependencies <your project>
- Observe the
node_modules
directory does not contain the scoped package as a symlink
Expected behavior (i.e. solution)
Scoped dependencies should appear in the local node_modules
folder.
What version of OC, Node.js and OS are you using?
- OC@0.48.15
- Will happen on any node / os version
Other Comments
This appears to be caused by this line: https://github.com/opencomponents/oc/blob/master/src/cli/domain/handle-dependencies/link-missing-dependencies.js#L10
Normally it would split the dependency name and version:
('foo@^1.0.0').split('@')[0] -> ['foo', '1.0.0'][0] -> foo
However, with a scoped package, we'll get an empty string (falsy):
('@scope/foo^1.0.0').split('@')[0] -> ['', 'scope/foo', '1.0.0'][0] -> ''
Happy to open a PR for this
Hi, thanks for submitting an issue. A PR would be great!