-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Using SDK in a React native project #931
Comments
As I've not developed React Native at all, I don't know how to solve this problem. Here is the |
I had to clone the fetcher project and add it to my monorepo packages. I deleted the code fragmen where it uses import2. From this
To this
This solved my problem, but having it cloned means I would have to manually perform updates each time. Perhaps the issue lies in checking if it's a node_process. Would a solution based on this be useful for implementing any fixes? |
Since Node v20, If the node_process checking logic occures the problem, how about removing the polyfill logic and using the built-in fetch function directly? In that case, |
It's a good proposal, but that would be a breaking change for projects using a version lower than v20. I'll leave it up to your discretion. |
Then |
In that case, the polyfill code would be like below: const polyfill = new Singleton(async (): Promise<typeof fetch> => {
const m: typeof globalThis | null = (() => {
if (typeof globalThis === "object") return globalThis;
else if (typeof global === "object") return global;
else if (typeof window === "object") return window;
else if (typeof self === "object") return self;
throw new Error("Unknown platform. No global object found.");
})();
m.fetch ??= ((await import2("node-fetch")) as any).default;
return m.fetch;
}); |
Okay, let me verify if this solution works and I'll confirm with you to proceed with a PR |
@CarlosUtrilla You can test it on the # BY NEXT TAG
npm install @nestia/fetcher@next
# OR DIRECT VERSIONING
npm install @nestia/[email protected] |
I tried it and it doesn't work, maybe for the reason mentioned here: https://stackoverflow.com/a/60562613 So I think the best solution is to implement the first option.
|
Then I'll publish the Node v20 option as v3.3 update. It would be published when |
Okay, I look forward to it. |
Problem Description
When using the Nestia SDK in a React Native project, an error related to dynamic import has been encountered, producing the following message:
This error seems to be related to the @nestia/fetcher
Attempted Solutions
Setting fetch to fetch option on Iconnection
Any proposal to solve this issue, please?
P.S: Sorry for my bad english
The text was updated successfully, but these errors were encountered: