-
Notifications
You must be signed in to change notification settings - Fork 584
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
Only export a CJS bundle (using rollup) #5882
Conversation
/* eslint-disable @typescript-eslint/no-var-requires -- We're exporting using CJS assignment */ | ||
/* eslint-env commonjs */ | ||
|
||
module.exports = require("./dist/bundle.node").Realm; |
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.
I don't love it, but it works 🙂
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.
At least we have proper entry points set for node and React Native. Let's break everything in v13 💣
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.
Can't wait for v13! 🧼
@@ -84,4 +85,13 @@ describe("Enums", function () { | |||
}); | |||
}); | |||
}); | |||
describe("WaitForSync", function () { |
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.
Is this part of CJS?
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.
This is me forgetting to add this enum test when doing the Flx Sync v2 PR 😉
module.exports = function (request, options) { | ||
if (request === "react-native") { | ||
// Ensure that "react-native" always resolve relative to the rootDir | ||
options.basedir = options.rootDir; | ||
} else if (request === "realm") { | ||
// Ensure the node binding is used when testing with Jest on node | ||
options.conditions = ["require", "default", "node"]; | ||
} | ||
return options.defaultResolver(request, 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.
@takameyer to be honest, I don't understand why this worked before.
- The first branch will ensure "react-native" from
@realm/react
is loaded, instead of the peer dependency ofrealm
(realm/node_modules/react-native
), as that yieldedInvariant Violation: __fbBatchedBridgeConfig is not set, cannot invoke native modules
errors - The second branch is to ensure the Node.js version of the SDK is loaded. If I didn't do this, I would be getting
TypeError: Cannot read properties of undefined (reading 'Helpers_get_table')
errors.
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.
Interesting. I've never seen those issues before. Why would this happen with cjs?
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.
I believe these (in packages/realm/src/tests
) also need to be updated:
- list.test.ts
- milestone-4.test.ts
- milestone-5.test.ts
- platform.test.ts
- schema-utils.test.ts
- updateschema.test.ts
- utils.ts
Other than that, LGTM 👍
@@ -84,4 +85,13 @@ describe("Enums", function () { | |||
}); | |||
}); | |||
}); | |||
describe("WaitForSync", function () { |
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.
This is me forgetting to add this enum test when doing the Flx Sync v2 PR 😉
@elle-j these are importing directly from source, so they don't need an update 👍 |
What, How & Why?
This supersedes #5853 and fixes #5857 by removing the ESM exports from the rollup config and adding CJS entrypoint files which export via
module.exports =
assignments as our v11 SDK does as well.☑️ ToDos
Breaking
label has been applied or is not necessary