Some necessary NPM modules are not in dependencies in package.json
MP-msft opened this issue · comments
Willing to submit a PR to fix?
- I am willing to submit a PR to fix
Requested priority
Normal
Products/applications affected
No response
Package version(s)
0.35.18
OS version(s)
No response
Platform
- iOS
- macOS
- win32
- windows
- android
Xcode version
No response
Please provide a reproduction of the bug
- create a blank RN app (e.g. w/ Expo)
https://reactnative.dev/docs/environment-setup - change runtime to "classic" -- by default it's "automatic" which will have another runtime issue with "use strict"
Please see related issue and how to change to "classic" runtime:
#1891
- install Fluent UI React Native and start on iOS (iOS has issue of missing both modules in dependencies below, whereas Android only has issue of midding "react-native-svg")
npm i @fluentui/react-native
- Observe:
4.1. add aTextV1
component to App.js -- "use-subscription" module is missing
Observe that "use-subscription" is in devDependencies: https://github.com/microsoft/fluentui-react-native/blob/main/packages/experimental/NativeFontMetrics/package.json
4.2 add aCheckboxV1
component to App.js -- "react-native-svg" is missing
Observe that "react-native-svg" is in devDependencies: https://github.com/microsoft/fluentui-react-native/blob/main/packages/components/Checkbox/package.json
"use-subscription" is used in Text
and "react-native-svg" is used in many other packages/components. They are the two that are found to be not in dependencies when they should, but there could be other modules having the same issue.
Actual behavior
Some NPM modules are missing after installing Fluent UI React Native via npm i @fluentui/react-native
It takes extra manual steps to install the modules to dependencies.
Expected behavior
It shouldn't take extra manual step to install the missing modules after installing Fluent UI React Native.
In other words, if the modules are needed, they should be in dependencies (if they are intended to be non-shared dependencies) or peerDependencies (if they are intended to be shared dependencies) instead of devDependencies (which are not available at runtime).
For react-native-svg
, the React Native CLI doesn't support auto linking transitive dependencies. Because of that, the end app generally has to also add packages with native modules as a direct dependency. If we add react-native-svg
as a direct dependency, and the end app has a different version of react-native-svg
, then you could run into issues with multiple versions of react-native-svg
(and it's native modules) present in node_modules. I think for that reason we kept react-native-svg
as a peerDependency. However, if that's causing issues, it might be good to revisit that decision.
For use-subscription
I remember there was something weird about the versioning of that package but I can't remember what.