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

Force commonjs imports for ledgerhq-react-native-hw-transport-ble #879

Merged
merged 2 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ shared-workspace-lockfile=true
enable-pre-post-scripts=true
hoist=false
strict-peer-dependencies=false
# See: https://github.com/actions/setup-node/issues/543#issuecomment-1182469390
loglevel=warn
# Disabled because it does not seem to be working and it regenerates the lockfile abusively
side-effects-cache=false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, i didn't even know about this file!

Copy link
Contributor Author

@elbywan elbywan Aug 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it's super useful to tweak pnpm behaviour

https://pnpm.io/npmrc


public-hoist-pattern[]=@babel/*
public-hoist-pattern[]=*eslint*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { useSelector } from "react-redux";
import { useTranslation } from "react-i18next";
import { Observable } from "rxjs";
import { InfiniteLoader } from "@ledgerhq/native-ui";
import { DeviceModelId } from "@ledgerhq/devices/src/index";
import { getInfosForServiceUuid } from "@ledgerhq/devices";
import { getInfosForServiceUuid, DeviceModelId } from "@ledgerhq/devices";
import logger from "../../logger";
import { BLE_SCANNING_NOTHING_TIMEOUT } from "../../constants";
import { knownDevicesSelector } from "../../reducers/ble";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
getInfosForServiceUuid,
} from "@ledgerhq/devices";
import type { DeviceModel } from "@ledgerhq/devices";
import { sendAPDU } from "@ledgerhq/devices/ble/sendAPDU";
import { receiveAPDU } from "@ledgerhq/devices/ble/receiveAPDU";
import { sendAPDU } from "@ledgerhq/devices/lib/ble/sendAPDU";
import { receiveAPDU } from "@ledgerhq/devices/lib/ble/receiveAPDU";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using /lib here ?

Copy link
Contributor Author

@elbywan elbywan Aug 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the whole point of this PR πŸ˜‰.

metro is unable to map @ledgerhq/devices/ble/… to either /lib/ble/… or /lib-es/ble/… because it does not support package exports.

Workarounds exist and are documented in the linked issue but it's not ideal at all to have to modify the metro config file.

Adding /lib here is not a big deal anyway since the react-native-hw-transport-ble package is only consumed by react-native clients and will never need to resolve the /lib-es version.

import { log } from "@ledgerhq/logs";
import { Observable, defer, merge, from, of, throwError } from "rxjs";
import {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"license": "MIT",
"private": true,
"packageManager": "pnpm@7.3.0",
"packageManager": "pnpm@7.9.0",
"repository": {
"type": "git",
"url": "https://github.com/LedgerHQ/ledger-live.git"
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.