oob React SPFx web part broken from yo due to Fabric 7 references
Category
- [ ] Question
- [ ] Typo
- [x] Bug
- [ ] Additional article idea
Expected or Desired Behavior
yo @microsoft/sharepoint generates a React web part which runs without errors
Observed Behavior
yo @microsoft/sharepoint generates a React web part which runs but produces voluminous source file resolution error messages
Steps to Reproduce
yo @microsoft/sharepoint (choose framework React web part, name HelloWorld, all other options are default.) npm install gulp serve or gulp bundle
Terminal window emits dozens of errors like the following:
@ ./node_modules/@uifabric/foundation/node_modules/@uifabric/utilities/lib/index.js 44:0-44
@ ./node_modules/@uifabric/foundation/lib/index.js
@ ./node_modules/office-ui-fabric-react/lib/Foundation.js
@ ./node_modules/office-ui-fabric-react/lib/components/Stack/Stack.js
@ ./node_modules/office-ui-fabric-react/lib/components/Stack/index.js
@ ./node_modules/office-ui-fabric-react/lib/Stack.js
@ ./node_modules/office-ui-fabric-react/lib/index.js
@ ./lib/webparts/helloWorld/components/HelloWorld.js
@ ./lib/webparts/helloWorld/HelloWorldWebPart.js
./node_modules/@uifabric/foundation/node_modules/@uifabric/utilities/lib/safeSetTimeout.js
(Emitted value instead of an instance of Error) Cannot find source file '../src/safeSetTimeout.ts': Error: Can't resolve '../src/safeSetTimeout.ts' in 'C:\Users\BillA\Documents\Projects\OfficeDev\HelloWorld\node_modules\@uifabric\foundation\node_modules\@uifabric\utilities\lib'
NonErrorEmittedError: (Emitted value instead of an instance of Error) Cannot find source file '../src/safeSetTimeout.ts': Error: Can't resolve '../src/safeSetTimeout.ts' in 'C:\Users\BillA\Documents\Projects\OfficeDev\HelloWorld\node_modules\@uifabric\foundation\node_modules\@uifabric\utilities\lib'
at emitWarning (C:\Users\BillA\Documents\Projects\OfficeDev\HelloWorld\node_modules\webpack\lib\NormalModule.js:117:16)
at C:\Users\BillA\Documents\Projects\OfficeDev\HelloWorld\node_modules\source-map-loader\index.js:80:7
at onError (C:\Users\BillA\Documents\Projects\OfficeDev\HelloWorld\node_modules\enhanced-resolve\lib\Resolver.js:65:10)
at loggingCallbackWrapper (C:\Users\BillA\Documents\Projects\OfficeDev\HelloWorld\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
at runAfter (C:\Users\BillA\Documents\Projects\OfficeDev\HelloWorld\node_modules\enhanced-resolve\lib\Resolver.js:158:4)
at innerCallback (C:\Users\BillA\Documents\Projects\OfficeDev\HelloWorld\node_modules\enhanced-resolve\lib\Resolver.js:146:3)
at loggingCallbackWrapper (C:\Users\BillA\Documents\Projects\OfficeDev\HelloWorld\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
at next (C:\Users\BillA\Documents\Projects\OfficeDev\HelloWorld\node_modules\tapable\lib\Tapable.js:252:11)
at C:\Users\BillA\Documents\Projects\OfficeDev\HelloWorld\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:40:4
at loggingCallbackWrapper (C:\Users\BillA\Documents\Projects\OfficeDev\HelloWorld\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
Web part runs normally - error messages presumably coming from webpack. I would categorise this as non-critical because the component does run.
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
We've seen similar things since last night when Office UI Fabric was updated to version 7. If you take a look at the package-lock.json file there's references to v 7, and new versions of React, even though you're just using OUIF 6. This seems to be an issue with the @uifabric/foundation that just did a minor update but still has dependencies on v 7 and the new React
Yes, pretty sure it's OUIF-related. But seeing React 16.7 which is normal for SPFx 1.82. I also have a version using React 16.8 which has same errors. I couldn't see a v7 reference but sounds like a good theory ;-)
Okay, see it now in @uifabric/foundation dependencies.
Thanks for sharing - we are now tracking this internally. Sorry for the inconvenience.
@JasonGore @JDHuntington.
Status - Issue has been identified and fix is being planned.
This is now resolved for 6. (Temporarily we are busted for 7, but it will be patched after.)
Here’s what happened:
We’ve thoroughly tested new releases of both 6 and 7 that they work and install correctly. Not the issue.
The yeoman template refers to an older build of 6 (6.154.0 I think) which had this range dependency:
@uifabric/foundation: >= 0.7.1 <1.0.0
We later discovered that range dependencies are bad for pre-releases, and switched them to use carets. Carets for prerelease packages do not bump the minor, but act as a tilde does for >0 majors. We had fixed this in OUFR a while ago, in around ~6.180.
When we released Fabric 7, we minor bumped the foundation pre-release, not realizing the range dependency was still out in the wild. This passed all of our tests, but we didn’t try to go back to every pre-release to understand npm’s behavior in this situation.
I’ve addressed by unpublishing the foundation minor releases. I tested yo @microsoft/sharepoint before and after the change. It now correctly installs fabric 6 bits.
For the fabric 7 bits, we will republish foundation as a major release, which will make this situation impossible to hit going forward.
Sorry for the disruption!
As issue has been resolved, closing this one as fixed. Thanks everyone for your participation on getting this issue resolved.
@dzearing - love this kind of direct information on what went wrong!
We are facing a similar issue again. This time it seems it is the @uifabric/utilities dependency for @types/react-dom. We saw that a new version has been published for the package, which now expects a version for @types/react-dom to lie between >=16.3.0 <17.0.0. It was earlier installing version 16.0.5 for the @types/react-dom and we now get an error saying it requires there are invalid peer dependencies.
Attaching the error screen.
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