Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #9226
Closed
Open
Issue created 5 years ago by Administrator@rootContributor
  • New related issue

  • Report abuse to administrator

  • New related issue

  • Report abuse to administrator

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

Open

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

  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

  1. Oh no!

    You are trying to upload something other than an image. Please upload a .png, .jpg, .jpeg, .gif, .bmp, .tiff or .ico.

    Incoming!

    Drop your designs to start your upload.
Tasks
0

No tasks are currently assigned. Use tasks to break down this issue into smaller parts.

Linked items
0

Link issues together to show that they're related. Learn more.

Activity


  • Administrator
    Administrator @root · 4 years ago
    Author Contributor

    Created by: stale[bot]

    This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

  • Administrator
    Administrator @root · 4 years ago
    Author Contributor

    Created by: jonenst

    Still unsolved

  • Administrator
    Administrator @root · 4 years ago
    Author Contributor

    Created by: skoging

    Same issue in workspaces with Yarn 2

  • Administrator
    Administrator @root · 4 years ago
    Author Contributor

    Created by: stale[bot]

    This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

  • Administrator
    Administrator @root · 4 years ago
    Author Contributor

    Created by: jonenst

    Up

    Le dim. 13 sept. 2020 à 20:29, stale[bot] notifications@github.com a écrit :

    This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

    — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub http://metis.lti.cs.cmu.edu:8023/facebook/create-react-app/-/issues/9226#issuecomment-691706825, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAVY6EDJPNDTYONF2TIJ3TSFUFO5ANCNFSM4OJGQVAQ .

  • Administrator
    Administrator @root · 4 years ago
    Author Contributor

    Created by: itaylor

    I had the same problem, ended up having to eject and remove ModuleScopePlugin

    I understand that it CRA wants to prevent me from doing import foo from '../../../../bar' but the way ModuleScopePlugin is implemented means you can't use the linking features of yarn, lerna, etc. My imports look like this import foo from 'bar' and are linked using my package manager, which should be fine IMO.

  • Administrator
    Administrator @root · 4 years ago
    Author Contributor

    Created by: idubrov

    For what it's worth, if you are using yarn v2, you can use their patch protocol to patch react-scripts to not include the ModuleScopePlugin (so you don't have to eject).

Please register or sign in to reply
0 Assignees
None
Assign to
Labels
2
issue: bug report issue: needs investigation
2
issue: bug report issue: needs investigation
    Assign labels
  • Manage project labels

Milestone
No milestone
None
Due date
None
None
None
Time tracking
No estimate or time spent
Confidentiality
Not confidential
Not confidential

You are going to turn on confidentiality. Only project members with at least the Reporter role, the author, and assignees can view or be notified about this issue.

Lock issue
Unlocked
1
1 participant
Administrator
Reference: facebook/create-react-app#9226

Menu

Explore Projects Groups Snippets