Comments (11)
Then I'll publish the Node v20 option as v3.3 update.
It would be published when ts-patch
fixes this issue: nonara/ts-patch#159
from nestia.
Since Node v20, fetch
becomes built-in function.
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, nestia
will no more support NodeJS v20 under versions.
from nestia.
https://github.com/samchon/nestia/blob/master/packages/fetcher/src/internal/FetcherBase.ts#L138-L140
https://github.com/samchon/nestia/blob/master/packages/fetcher/src/internal/FetcherBase.ts#L199-L215
As I've not developed React Native at all, I don't know how to solve this problem.
Here is the fetch()
function used in @nestia/e2e
. Can you fix the code through PR?
from nestia.
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
const polyfill = new Singleton(async (): Promise<typeof fetch> => {
function is_node_process(m: typeof global | null): boolean {
return (
m !== null &&
typeof m.process === "object" &&
m.process !== null &&
typeof m.process.versions === "object" &&
m.process.versions !== null &&
typeof m.process.versions.node !== "undefined"
);
}
if (typeof global === "object" && is_node_process(global)) {
const m: any = global as any;
m.fetch ??= ((await import2("node-fetch")) as any).default;
return (m as any).fetch;
}
return self.fetch;
});
To this
const polyfill = new Singleton(async (): Promise<typeof fetch> => {
function is_node_process(m: typeof global | null):
return self.fetch;
});
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?
from nestia.
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.
from nestia.
Then globalThis
works in the ReactNative? Instead of global
, using globalThis
will be another option.
from nestia.
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;
});
from nestia.
Okay, let me verify if this solution works and I'll confirm with you to proceed with a PR
from nestia.
@CarlosUtrilla You can test it on the next
version: 3.2.6-dev.20240624
.
# BY NEXT TAG
npm install @nestia/fetcher@next
# OR DIRECT VERSIONING
npm install @nestia/[email protected]
from nestia.
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.
.... In that case,
nestia
will no more support NodeJS v20 under versions.
from nestia.
Okay, I look forward to it.
Thank you very much for the support.
from nestia.
Related Issues (20)
- Enhance `@nestia/sdk` performance by abandoning `ts-node` HOT 5
- is tsconfig's strictPropertyInitialization property safe to set false? HOT 3
- binded arguments in the "path" between function's decorator and parameters' decorators are different HOT 11
- Text after the comma disappears in TypedFormData.Body HOT 2
- Cannot find module 'get-funtion-location' HOT 2
- In version `3.1.4` of @nestia/core, `nestia sdk` throws a `no transform has been configured` error. HOT 2
- [Bug Report] Parsing incorrect module paths HOT 1
- [Question or Bug Report] decompose option's bug on swagger generator with special tags, defined anonymous interface. HOT 2
- Generic interfaces are not included in SDK when using @WebSocketRoute and clone: true HOT 4
- `TypedParam` should use validator configured in tsconfig just like `TypedQuery` / `TypedBody` HOT 2
- How to use on Nest monorepo structure ? HOT 2
- RangeError: Maximum call stack size exceeded HOT 12
- Nestia SDK not working with Monorepo or Thirdparty HOT 1
- e2e Generation is failed HOT 5
- Long output type names cause syntax errors HOT 1
- Separate `@nestia/benchmark` from `@nestia/e2e`
- `TypedParam` does not support object destructuring without name parameter like NestJS Param
- Is there an reason to `config.swagger.decompose` defaults to false? HOT 3
- (Off topic) how hard is to use nestia capabilities outside nestjs controller?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nestia.