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

Webpack Build Error Due to Nullish Coalescing Operator in Recent Update #591

Closed
Menny1337 opened this issue Jun 19, 2023 · 10 comments · Fixed by #594
Closed

Webpack Build Error Due to Nullish Coalescing Operator in Recent Update #591

Menny1337 opened this issue Jun 19, 2023 · 10 comments · Fixed by #594

Comments

@Menny1337
Copy link

Hello Fluent UI team,

In a recent change to the @fluentui/react-icons package, a syntax error has been introduced which breaks builds using Webpack. The file in question is IconDirectionContext.js where a nullish coalescing operator (??) is used.

Here is the offending code:

export const useIconContext = () => React.useContext(IconDirectionContext) ?? IconDirectionContextDefaultValue;

The error message thrown by Webpack is as follows:

@fluentui/react-icons/lib/contexts/IconDirectionContext.js 5:76
Module parse failed: Unexpected token (5:76)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

This issue seems to stem from the nullish coalescing operator (??) not being recognized by certain Webpack configurations. This was not an issue before the recent changes to IconDirectionContext.js.

In the meantime, we have mitigated this issue by reverting to an older version of the @fluentui/react-icons package. However, I believe this issue should be addressed at the source. One possible solution could be to revise the use of newer syntax that is not universally supported or to modify the target setting in the tsconfig to ensure the compiled code is compatible with more environments.

The line that introduced this issue can be found here.

Thank you for your attention to this matter.

@pradeept95
Copy link

I am having the same issue!

[14:01:59] Error - [webpack] 'dist':
./node_modules/@fluentui/react-icons/lib/contexts/IconDirectionContext.js 5:76
Module parse failed: Unexpected token (5:76)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| const IconDirectionContextDefaultValue = {};
| export const IconDirectionContextProvider = IconDirectionContext.Provider;

export const useIconContext = () => React.useContext(IconDirectionContext) ?? IconDirectionContextDefaultValue;
@ ./node_modules/@fluentui/react-icons/lib/contexts/index.js 1:0-39 1:0-39
@ ./node_modules/@fluentui/react-icons/lib/index.js
@ ./node_modules/@fluentui/react-select/lib/components/Select/useSelect.js
@ ./node_modules/@fluentui/react-select/lib/components/Select/Select.js
@ ./node_modules/@fluentui/react-select/lib/components/Select/index.js
@ ./node_modules/@fluentui/react-select/lib/Select.js
@ ./node_modules/@fluentui/react-select/lib/index.js
@ ./node_modules/@fluentui/react-components/lib/index.js
@ ./lib/webparts/contractManagement/ContractManagementWebPart.js

@westleyMS
Copy link

westleyMS commented Jun 20, 2023

I have run into the exact same stack in an SPFx project using fluentUI.

fixed by rolling back to 2.0.203 on the react-icons component.

@CasparRubin
Copy link

Same here trying to run this demo: https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-fluentui-9

Followed all instructions...
node -v: v16.18.1
npm -v: 8.19.2
"npm install" into "gulp serve" and i get the error mentioned above

Error - [webpack] 'dist': ./node_modules/@fluentui/react-icons/lib/contexts/IconDirectionContext.js 5:76 Module parse failed: Unexpected token (5:76) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

@karthik15981
Copy link

Ran into the same issue as well and our temporary fix was to use "npm overides" to force React Fluent UI components to use 2.0.203

@AnasSahel
Copy link

I Ran into the same issue as well. Didn't find a solution unfortunately

@kboul
Copy link

kboul commented Jul 24, 2023

This is still reproducible using version 2.0.207. Had to revert to @fluentui/react-icons 2.0.202 but still not passing while before it was.

@Linkybill
Copy link

same Problem here...

@spencer-nelson
Copy link
Member

The Nullish Coalescing operator from IconDirectionContext was removed in #625 which preceeded 2.0.214. Please confirm you have that, or a later version, or otherwise point to the usage in a more recent version of the library.

@Linkybill
Copy link

I have installed latest version of fluent ui react components

"@fluentui/react-components": "^9.35.1".

Which version of fluentuireactcomponents should I install?

@spencer-nelson
Copy link
Member

Sorry, but that isn't a dependency of this library (that I'm aware of) and I don't know the answer. Further, I apologize for the confusion, but I suggest you open an issue in the microsoft/fluentui repository related to that package (https://github.com/microsoft/fluentui/tree/master/packages/react-components)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants