Yarn 2 "portal:" local components import compilation failure because of ModuleScopePlugin
Created by: jonenst
Describe the bug
Description here: https://stackoverflow.com/questions/61530712/module-not-found-error-using-yarn-2-to-link-react-components
TLDR:
When adding "MyExternalComponent": "portal:../MyExternalComponent"
dependencies to package.json, and importing the component with import Mycomponent from MyExternalComponent
, the build fails because of the ModuleScopePlugin restriction "You attempted to import components which falls outside of the project src/ directory"
Which terms did you search for in User Guide?
"yarn 2 ModuleScopePlugin" "portal: ModuleScopePlugin"
Environment
yarn2
(paste the output of the command here.)
Steps to reproduce
(Write your steps here:)
- create a package in folder Foo
- yarn dlx create-react-app Bar
- add "Foo": "portal:../Foo" to Bar's package.json 4 build Bar
Expected behavior
Should work
Actual behavior
compilation error: "You attempted to import components which falls outside of the project src/ directory"
Reproducible demo
https://bitbucket.org/cjmyles/yarn2-link/commits/e02b93771dfded0215bdba456d31aea011367807