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

nova-facade-react: import invariant form "invariant"; to ensure it works in web and react native. #2

Closed
tom-un opened this issue Sep 2, 2021 · 3 comments
Assignees

Comments

@tom-un
Copy link

tom-un commented Sep 2, 2021

In TMP, the nova-facade-react package depends on invariant and imports the default as invariant:

e.g.
import * as invariant from "invariant";
https://domoreexp.visualstudio.com/Teamspace/_git/teams-modular-packages?path=%2Fpackages%2Fnova%2Ffacade%2Fnova-facade-react%2Fsrc%2Fgraphql%2Fhooks.ts&version=GBmaster

When this code is used in react-native bundles, the result is an object named invariant instead of a function named invariant (see zertosh/invariant#32).

For the code to work in web and react native, the imports should change to
import invariant from "invariant";

In 1JS, I patched nova-facade-react with this change and verified it works in both web and native. https://office.visualstudio.com/Office/_git/1JS/pullrequest/978506

@kerrynf kerrynf self-assigned this Sep 9, 2021
@kerrynf
Copy link
Contributor

kerrynf commented Sep 11, 2021

Oddly, updating the reference like above breaks the unit tests in TMP with the following error. TypeError: invariant_1.default is not a function

Hopefully this won't be an issue in this repo.

@tom-un
Copy link
Author

tom-un commented Sep 13, 2021

Could TMP's TS config be missing the allowSyntheticDefaultImports: true as referenced in zertosh/invariant#32 ?

@kerrynf
Copy link
Contributor

kerrynf commented Sep 21, 2021

This should be done in the initial package commit.

@kerrynf kerrynf closed this as completed Sep 21, 2021
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

No branches or pull requests

2 participants