Skip to content

Module not found - Wrong @fluentui imports cause webpack build errors #1763

Closed
@hohenp

Description

@hohenp

Category

[ ] Enhancement

[X ] Bug

[ ] Question

Version

Version: 3.17.0

Expected / Desired Behavior / Question

We are using the spfx-controls-react within a webpack project and would expect to build it without webpack errors.

Observed Behavior

We are using the spfx-controls-react within a webpack project. When we build the project we get several webpack errors like:
image

Steps to Reproduce

We could identify the used imports of the @FluentUI package to cause that issue:
You are using for example the following import:
import { ActionButton, PrimaryButton } from "@fluentui/react/lib/components/Button";
The correct import would be:
import { PrimaryButton } from '@fluentui/react/lib/Button';
as described on the fluent ui page

You can also check the export section of the @FluentUI package.json file.
There for example the button is declared as

"./lib/Button": {
      "types": "./lib/Button.d.ts",
      "import": "./lib/Button.js",
      "require": "./lib-commonjs/Button.js"
    },

so without the /components/ section of the import you are using.

For testing we fixed the wrong imports in the following files and that fixed all build errors we got
image

Could you please check all your imports of the @FluentUI package?

Thanks
Pascal

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:fixed-next-dropIssue will be fixed in upcoming release.type:enhancementNew feature or enhancement of existing capability

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions