Skip to content
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

Unable to resolve linked dependencies using SPFx 1.19 & pnpm workspaces #145

Closed
jacksonv1lle opened this issue Aug 19, 2024 · 7 comments
Closed

Comments

@jacksonv1lle
Copy link

I have monorepo set up with single spfx web part and two spfx libraries.

MyWebpart -> depends on MyLibrary -> depends on MyOtherLibrary

I am installing the packages using pnpm and the link-workspace-packages to link the dependecies together.

When running the fast-serve task, everything builds fine but the web part fails to load in the browser.

It works fine using the regular gulp serve command

spfx libraries: 1.19.0
spfx-fast-serve-helpers:1.19.2
pnpm: 9.7.1
node: 18.19.1

I have reproduced the problem at this repository.

Thanks

@MatthewSammut
Copy link

MatthewSammut commented Sep 6, 2024

Hello, is there an update regarding this as I'm also facing the same issue. Thanks in advance.

@jacksonv1lle
Copy link
Author

No luck. I tried with version 1.19.3 also but still not working with pnpm for me. I have been using the SPFx gulp serve.

@s-KaiNet
Copy link
Owner

s-KaiNet commented Sep 6, 2024

I didn't have a chance to have a deep look at the issue yet. This weekend I have some time and will try to fix this one and some other issues added recently. Sorry for the inconvenience.

@s-KaiNet
Copy link
Owner

s-KaiNet commented Sep 8, 2024

I found where the problem is, it could be fixed, but require some time, will wok on it this week.

@jacksonv1lle
Copy link
Author

That's great. Thanks for your help

@s-KaiNet
Copy link
Owner

s-KaiNet commented Sep 10, 2024

I published the 1.19.4 version, where I believe the issue is fixed.
I don't know which commands do you use for updating dependencies inside pnpm workspaces, I used below commands to install the latest version (based on the sample repo you provided, should be executed in the root workspace directory):

pnpm i [email protected] --filter @spfxtesting/my-webpart -DE
pnpm i [email protected] --filter @spfxtesting/my-other-library -DE
pnpm i [email protected] --filter @spfxtesting/my-library -DE

then you should consequently execute npm run serve starting from the library without dependencies (my-other-library), then npm run serve inside my-library (because it depends on my-other-library) and finally for my-library. You should wait until it's fully compiled at each step, and only after that execute next npm run serve.

Please try it and tell if it fixes the issue.

PS. In your sample repository you use old format of fast-serve config, which will work, because it's backward compatible, but moving forward it's better to use a newer one.
The one you have:

{
  "$schema": "https://raw.githubusercontent.com/s-KaiNet/spfx-fast-serve/master/schema/config.1.1.schema.json",
  "cli": {
    "isLibraryComponent": true,
    "port": 4322
  }
}

should be changed to:

{
  "$schema": "https://raw.githubusercontent.com/s-KaiNet/spfx-fast-serve/master/schema/config.v2.schema.json",
  "serve": {
    "isLibraryComponent": true,
	 "port": 4322
  }
}

@jacksonv1lle
Copy link
Author

Thank you for this. Everything is working fine again within the yarn monorepo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants