Loading...

Explicit package exports in the latest version of Fluent UI might break your PCF path imports

Explicit package exports in the latest version of Fluent UI might break your PCF path imports

If you are using Fluent UI in your code components (PCF) you probably are also using path-based imports to reduce your bundle size. This technique ensures that when you build your code component, the bundle doesn't include the entire Fluent UI library, but instead just the components that you need. With the recent update to Fluent UI, you might receive an error similar to the following:

ERROR in ./somefile.tsx 
Module not found: Error: Package path ./lib/components/CommandBar is not exported from package C:\src\CommandBar\node_modules\@fluentui\react (see exports field in C:\demo4\CommandBar2\node_modules\@fluentui\react\package.json)

This is probably caused by your paths pointing to a folder that is not included in the new explicit export paths that have been added to the Fluent UI react package

To ensure that you maintain compatibility with each update to the Fluent UI library, instead of using:

import { CommandBar } from '@fluentui/react/lib/components/CommandBar';

You should instead use:

import { CommandBar } from '@fluentui/react/lib/CommandBar';

See more information in the docs: Best practices for code components - Power Apps | Microsoft Docs

That's all for now!

@ScottDurow

Published on:

Learn more
Need help with this product?

We can help you with Explicit package exports in the latest version of Fluent UI might break your PCF path imports

If you want help implementing, troubleshooting, or improving this product, contact us and we’ll point you in the right direction.

Develop 1 - Dynamics 365 Architecture Services
Develop 1 - Dynamics 365 Architecture Services

Share post:

Related posts

React 18 is not compatible with Fluent UI and how to work around it in PCF projects

React version 18 has recently been pushed into npm which is great if all of your components support it, however, if you are working with Flu...

4 years ago

Newsletter

Get the latest Dynamics 365 and Power Platform content in your inbox

A curated digest of community blogs, product news, videos, and podcasts — delivered without the noise.

Weekly updates Unsubscribe anytime Fresh community picks
We use your email only for the newsletter and you can unsubscribe at any time.
By subscribing, you agree to the privacy policy.