-
Notifications
You must be signed in to change notification settings - Fork 332
Issues, Workarounds and Tricks
A non-exhaustive list of things we had to do in order to make the monorepo work.
Why: pnpm
is stricter than yarn
compared to handling transitive dependencies.
Solution: Add them as dependencies or devDependencies to the related package.json file.
Why: pnpm
hoists dependencies in a workspace context and can duplicate them if they have different peer dependencies version.
Solution:
- LLM: force metro to resolve a dependency from the LLM node_modules by adding it to the
FORCED_DEPENDENCIES
array in themetro.config.js
file. - LLD: force webpack to resolve a dependency from the LLD node_modules
- Global: add it inside the
readPackage
function of the.pnpmfile.cjs
file to force-remove its peer dependencies.
'XXX' is not recognized as an internal or external command
Why: Running a binary by specifying its path in an npm script will not work on Windows. It is needed to prepend the command with a call to node.exe
.
Solution: Use the x-ref
homemade package to run binaries from an npm script in a cross-platform compatible way.
Why: We use pnpm
now and some tooling we use (namely turborepo
) crawls all the folders and searches for yarn lockfiles to determine which package manager to use.
Solution: Delete each and every yarn lockfile.
- Use
node-libs-react-native
nodejs shims instead ofrn-nodeify
Why: Because nodeify updates package.json recursively by adding browser
and react-native
keys and this mutates the pnpm store.
Solution: Use node-libs-react-native
which means adding some requires in the metro.config.js
file and an import in the entry file.
Why: See https://github.com/facebook/watchman/issues/105
Solution: @rnx-kit/metro-config
provides a default config which watches every relevant folders instead of just watching the nested llm node_modules.
Why: See https://github.com/facebook/metro/issues/1
Solution: Use @rnx-kit/metro-resolver-symlinks
as a main resolver in the metro.config.js
file.
Why: The symlink resolver uses the node.js resolver under the hood and tries to resolve the location of the package.json file for each module. For packages that use subpath exports it will not work if they do not provide a path for the package.json
file as subpath exports are exclusive. See https://nodejs.org/api/packages.html#subpath-exports
Solution: Add a fallback resolver in the metro.config.js
file.
Why: Expo uses a custom algorithm to crawl dependencies and link them if they include compatible files. But it will fail for most deps because of the pnpm workspace node modules structure and symlinks.
Solution: Add custom NODE_PATH
environment variables pointing to relevant directories. This is added in the Podfile
for ios builds and in the Fastfile
for android builds.
Why: we require ruby scripts from dependencies based on their node_modules location and with pnpm it could be tricky to hardcode it.
Solution: run a small node script to resolve the location from ruby.
Why: RNAnalytics
redefined this header symbols for an unknown reason…
Solution: Patch on postinstall the RNAnalytics.h
file to force importing the right header <React/RCTBridgeModule.h>
.
Why: pnpm
will not rebuild dependencies properly and there will be a mismatch between the local nodejs version and the electron one.
Why: Electron bundler crawls production dependencies and packs them inside an .asar file inside the binary. With the standard pnpm install with symbolic links and hoisting it will fail to copy the packages properly.
Solution: Use the --package-import-method=copy
and --node-linker=hoisted
flags when bundling the app.
In the build_app.yml github action workflow, using pnpm i --filter="live-desktop..." --no-frozen-lockfile --unsafe-perm
to install only the smallest subset of depencencies results in an error while trying to build the app later on.
ERROR Cannot read property 'name' of undefined
Workaround: Use pnpm i
while pnpm
fixes this.
- Ledger Live Desktop
- Ledger Live Mobile
-
Ledger Live Common
- Introduction
- Currency Models
- Currency Bridge
- Account
- Account Bridge
- apps
- appsCheckAllAppVersions
- ledger-live bot
- Canonical Ways to Investigate Bugs
- Coin Integration Introduction
- Countervalues
- Packages Duplicates
- Derivation
- Developing with CLI
- Developing
- Gist Firmware Update
- Gist Transaction
- Hardware Wallet Logic
- Socket
- Assorted tips
- Integration Tests
- Process
- Monorepository Migration Guide
- Issues, Workaround and Tricks
- Common CI Troubleshooting
- Create staging builds using the CI
- Deprecated