-
Notifications
You must be signed in to change notification settings - Fork 907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using a component with different peer dependencies depending from the context #5251
Conversation
…age.json` This change was need to support injection in Bit workspace: teambit/bit#5251
…age.json` (#4223) This change was need to support injection in Bit workspace: teambit/bit#5251
5370470
to
1bc052d
Compare
69ca654
to
6878374
Compare
fe1e59a
to
e5df18e
Compare
if (!end) return path.basename(resolvedModulePath); | ||
const versionStr = head(end.split('/')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be not the best solution but it does fix a crash when the path doesn't contain '@'. I am open to suggestions.
41abd6f
to
8766c56
Compare
8766c56
to
68cdaa2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I reviewed the compilation part. I'm less familiar with the rest.
ac96357
to
0c7cf0a
Compare
0c7cf0a
to
a7ea61d
Compare
d43bd35
to
e9c00ea
Compare
abd1f78
to
99c96f9
Compare
e5b5593
to
a41d6b0
Compare
This is closed by #5443 |
Related PRs:
Proposed Changes
As of this pull request, this feature will be only supported by pnpm as the package manager (but both the hoisted and isolated
nodeLinker
will work).A new optional setting added to the
dependency-resolver
aspect:rootComponents
.rootComponents
is an array of component package names.Root components are installed in isolation from the workspace. None of the dependencies of root components are symlinked from the workspace. Instead, the dependencies of root components are copied (or hard linked) into the
node_modules
of the root component.Root components are installed at
<workspace root>/node_modules/<root component pkg name>/node_modules/<root component name>
. The dependencies of the root component are installed either inside the virtual store (node_modules/.pnpm
) or hoisted inside node_modules using Yarn's hoisting algorithm (pnpm uses Yarn's hoisting algorithm for the "hoisted" linker).Let's see how it will work on the following example:
app1
andapp2
are listed as rootComponents.In this case, Bit will create the following
node_modules
structure:See how the files in
node_modules/.pnpm/button+react@16/node_modules/button/
are not symlinks? It is important to have real files in the virtual store for proper resolution of dependencies. So the react innode_modules/.pnpm/button+react@16/node_modules/button/dist/index.js
will be resolved fromnode_modules/.pnpm/button+react@16/node_modules/react/
, while the react fromnode_modules/.pnpm/button+react@17/node_modules/button/
will be resolved fromnode_modules/.pnpm/button+react@17/node_modules/react/
Changes to compilation and linking
All the components in the virtual store should have a
dist
folder and apackage.json
file.The compilation aspect accepts a list of target directories instead of a single target directory. So instead of just compiling the sources of button to
node_modules/button/dist
, bit compiles the sources of button also to the following locations:The
package.json
files are linked as a separate task after installation is complete by the pnpm installation engine. So thepackage.json
file that is generated intonode_modules/button/package.json
is hard linked into:Other changes