s-KaiNet / spfx-fast-serve

Improve your SharePoint Framework development flow by speeding up the "serve" command :rocket:
MIT License
138 stars 11 forks source link

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

Closed jacksonv1lle closed 2 months ago

jacksonv1lle commented 3 months ago

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 commented 2 months ago

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

jacksonv1lle commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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

jacksonv1lle commented 2 months ago

That's great. Thanks for your help

s-KaiNet commented 2 months ago

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 spfx-fast-serve-helpers@1.19.4 --filter @spfxtesting/my-webpart -DE
pnpm i spfx-fast-serve-helpers@1.19.4 --filter @spfxtesting/my-other-library -DE
pnpm i spfx-fast-serve-helpers@1.19.4 --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 commented 2 months ago

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