-
Notifications
You must be signed in to change notification settings - Fork 1k
Referencing office-ui-fabric-react as external #1344
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
Comments
You were following this guidance: https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/basics/add-an-external-library#share-a-library-among-multiple-web-parts ? You should be able to reference office-ui-fabric-react as an external, but you must One thing to be aware of is that office-ui-fabric-react has breaking changes from time-to-time so it cannot be packaged in the same way as the SPFx Framework libraries, which are guaranteed to be backwards compatible. |
hi @SPParseError, since seems to be answered by our engineering, closing for now. Let's reopen if needed. Thx. |
Hi, I tried it once again. Here is my externals section in config.json : Here is my import statement in the webpart : I have this error when running gulp serve : Looks like I would need to add a "globalName" statement in the external declaration. If I do, I don't have this error. But then the code fires an error saying "React" does not exist, and I can't declare "React" as a dependency in externals. @VesaJuvonen should we reopen it ? |
Seeing the same behavior @SPParseError . This makes it a particular pain to externalize any module that has a dependency upon React. The version of React that loads into the page (15.6.2 at this time) doesn't expose itself as a global variable, which office-ui-fabric is trying to access. |
Any solution? |
It is not unfortunately supported to reference Office UI Fabric as an external package as that will cause you version exceptions. Recommendation and how to use Office UI Fabric React is covered in following documentation - https://docs.microsoft.com/en-us/sharepoint/dev/spfx/office-ui-fabric-integration. If you have any issues with this, would suggest to open a new issue so that your comments or findings will not get buried on closed issues. |
The UI Fabric React was not working using the node_module link. So we got a workaround to fix this issue. This will compile properly. However if you deploy and add the web part to a page it will through react not found error. Once this is done the web part loads fine. I know this is not the correct way but this will get your web parts working and will not create large bundle files. |
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues |
Uh oh!
There was an error while loading. Please reload this page.
Category
Expected or Desired Behavior
As I have multiple webparts in my project, I would like to reference office-ui-fabric-react as external, so that it does not get bundled with each webpart.
If I simply add the reference in externals in config.json, i do have an external file generated, and my webparts files go from ~800kb to ~100kb. But when I test it in the workbench, or in a "production" site, I get an error saying the component has a dependency on a module "office-ui-fabric-react" that is not referenced in the manifest. Error goes away if I add a "globalName" in my external reference in config.json (procedure for non AMD modules). But then a javascript error occures because it gets loaded before React.
However, doing researches, I find in the official documentation that I should use Fabric React that shipped with the generator. Samples show non external references.
Scaffholded a new project with latest version of the generator. I take all references in package.json, update my project's package.json and reinstall everything in node_modules. I still need to add (npm install) office-ui-fabric-react in my project to be able to reference its components
My question is :
Thanks !
The text was updated successfully, but these errors were encountered: