Skip to content

Yarn 2 "portal:" local components import compilation failure because of ModuleScopePlugin #9226

Description

@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:)

  1. create a package in folder Foo
  2. yarn dlx create-react-app Bar
  3. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions