-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix(package.json) Replace 'module' field with 'export' in package.json #2090
base: master
Are you sure you want to change the base?
Conversation
Hi, thanks for your contribution! |
Have you verified the mobile app also builds ok? |
I just run the app on iOS and build via metro went just fine. What's interesting though, it shouldn't build due to Metro not supporting "exports" fields yet (facebook/metro#670), however conducting more experiments I noticed that metro actually takes the package from the "browser" field, not "modules". Even in log messages it seems like they treat "browser" as "main" field (if we specify wrong package in "browser" field - the error from metro tells that field "main" points to a non-existent package 🤷) Btw. when you work on the lib, how do you link it to the mobile app locally? Metro doesn't seem to follow symlinks so can't do typical |
Another option would be to add the
You can use |
Replacing 'browser' with 'react-native' and pointing to ESM module works fine, though it throws one warning about circular dependency. Do you want me to fix it as part of this PR too? I didn't get that warning using current version of the lib, so I'm thinking that RN currently uses the UMD version of the lib, not the ESM. |
Hum, I was convinced we were using the ESM build, I may be wrong. Yeah we should get the cycle fixed if that's the only one. |
@@ -23,7 +23,7 @@ | |||
* | |||
* @constructor | |||
*/ | |||
export default function TraceablePeerConnection(rtc: RTC, id: number, signalingLayer: any, pcConfig: object, constraints: object, isP2P: boolean, options: { | |||
export default function TraceablePeerConnection(rtc: any, id: number, signalingLayer: any, pcConfig: object, constraints: object, isP2P: boolean, options: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing RTC import from TraceablePeerConnection.js
results in missing type here.. not sure if we can do something about that right now, thoughts?
I fixed the circular dependency in latest commit @saghul |
Should I change anything, or we can consider this fix complete? :) |
This PR updates package.json and replaces currently used 'module' field with a recommended by NodeJS 'export' field. According to documentation the 'module' field is ignored by NodeJS and only used by bundlers. After changing it however everything seems to be building fine.
The reasoning behind this change:
With this change it's possible to import the package without any hiccups:
I noticed that in jitsi-meet app you're importing the package like that already, but I'm not entirely sure why it works for you, perhaps you got some extra configuration that resolves modules by looking at that 'module' field 🤔