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

SPFx PnP Controls depends on MGT #918

Closed
siata13 opened this issue May 28, 2021 · 9 comments
Closed

SPFx PnP Controls depends on MGT #918

siata13 opened this issue May 28, 2021 · 9 comments
Labels
status:fixed-next-drop Issue will be fixed in upcoming release.

Comments

@siata13
Copy link
Contributor

siata13 commented May 28, 2021

Category

[x] Enhancement

[x] Bug

[ ] Question

Version

PnP controls in version 3.1

Observed Behavior

PnP Controls package has a dependency on @microsoft/mgt (Graph Toolkit) which causes problems in case 2 web parts using controls are loaded on the page:

image

Expected / Desired Behavior / Question

The solution could be to switch to mgt-spfx (https://www.npmjs.com/package/@microsoft/mgt-spfx), but it brings additional problems to always install the latest version of the solution of relaying on PnP controls along with mgt-spfx.sppkg to provide all the functionalities.

Could the controls relaying on mgt be moved to separate project??

Thanks!

@ghost
Copy link

ghost commented May 28, 2021

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 label May 28, 2021
@aaclage
Copy link
Contributor

aaclage commented May 28, 2021

@joelfmrodrigues @AJIXuMuK

I think this issue was fixed with "@microsoft/mgt": "^2.2.0".
with incorporation of npm install @microsoft/mgt-spfx
mgt-spfx

@AJIXuMuK
Copy link
Collaborator

I'll check that later. We've already have v2.2 in beta.

@joelfmrodrigues
Copy link
Collaborator

@siata13 just to double-check if this is not a scenario similar to what I experienced this week at work, are you using the PnP controls package directly in your web part solution, or via a SPFx library component solution?

@AJIXuMuK
Copy link
Collaborator

I was able to repro it on beta version as well. But only if you use mat-dependent control (MyTeams).
If you use any other control from the library - everything works fine.

I will check what's the best approach here. Maybe the best thing is to remove mgt dependency at all.

@siata13
Copy link
Contributor Author

siata13 commented May 29, 2021

@joelfmrodrigues I use it in web part solutions.
@AJIXuMuK I am not using MyTeams control. If needed I can try to get deep understanding why it happens on my end.

But I believe that moving control relying on MGT to separate library would make it much easier.

Thanks a lot for checking!

@AJIXuMuK
Copy link
Collaborator

@siata13 please check why it's happening.
My only assumption is non direct import from library.
Like import { WebPartTitle } from @pnp/spfx-react-controls instead of import { WebPartTitle } from @pnp/spfx-react-controls/lib/WebPartTitle

@siata13
Copy link
Contributor Author

siata13 commented Jun 2, 2021

@AJIXuMuK I have found the problematic part of the code which wasn't related to pnp controls as I initially thought.
The import strategy you suggested would be sufficient to avoid the problem, but nevertheless I think mgt-spfx is the only way to go.

Thanks for your time and support!

@joelfmrodrigues
Copy link
Collaborator

Just pushed some changes originally done by @joaojmendes on a PR that should fix this issue by using mgt-spfx.
I have also updated the documentation of MyTeams (the control that uses mgt) to include the instruction for installing the mgt-spfx library. Tested on my tenant and the error was resolved after the changes were applied.

Please note this is relevant for the MyTeams control. For anything else, use direct imports as suggested by @AJIXuMuK
import { WebPartTitle } from @pnp/spfx-react-controls/lib/WebPartTitle

@joelfmrodrigues joelfmrodrigues added status:fixed-next-drop Issue will be fixed in upcoming release. and removed Needs: Triage 🔍 labels Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:fixed-next-drop Issue will be fixed in upcoming release.
Projects
None yet
Development

No branches or pull requests

4 participants