opencomponents / oc

OpenComponents, serverless in the front-end world for painless micro-frontends delivery
https://opencomponents.github.io/
MIT License
1.43k stars 122 forks source link

Scope package dependencies are not linked during oc package #1178

Closed Taiters closed 3 years ago

Taiters commented 3 years ago

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:

  1. Create a component which has a scoped dependency, such as @babel/core
  2. From a different directory, which contains a node_modules folder, run oc package --useComponentDependencies <your project>
  3. 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?

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

matteofigus commented 3 years ago

Hi, thanks for submitting an issue. A PR would be great!