-
Notifications
You must be signed in to change notification settings - Fork 1
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
CommonJS support #1
Comments
Sounds good, I will give it a try. But I think since you introduced code analysis, it won't work without a build step (before each run) because of bun transpile step, for example: // Bun
let is = isFnUse(
'set',
`(context) => {
if (handleOrigin(context.set, context.request), handleMethod(context.set), exposedHeaders.length)
context.set.headers["Access-Control-Allow-Headers"] = typeof allowedHeaders === "string" ? allowedHeaders : allowedHeaders.join(", ");
if (maxAge)
context.set.headers["Access-Control-Max-Age"] = maxAge.toString();
return new Response("", {
status: 204
});
}`
);
console.log(is); // true
// Node
is = isFnUse(
'set',
`context => {
handleOrigin(context.set, context.request);
handleMethod(context.set);
if (exposedHeaders.length) context.set.headers['Access-Control-Allow-Headers'] = typeof allowedHeaders === 'string' ? allowedHeaders : allowedHeaders.join(', ');
if (maxAge) context.set.headers['Access-Control-Max-Age'] = maxAge.toString();
return new Response('', {
status: 204
});
}`
);
console.log(is); // false bugs in |
I got it working without using elysia-polyfills/scripts/runtime.js Lines 38 to 46 in 302ccea
elysia-polyfills/scripts/runtime.js Lines 51 to 57 in 302ccea
I'll look into CommonJS support tomorrow |
CommonJS support should be added without build-step in yarn create elysia my-elysia-app --template node If you want to support ESM hybrid with CJS in Elysia you can follow this blog post. I implemented the same approach. Furthermore you have to use |
Elysia 0.5 add support for CommonJS by default, this should allow us to drop the additional step of using CLI to convert Elysia modules to CommonJS.
It would be nice if would you updated the package to support CommonJS as well.
The text was updated successfully, but these errors were encountered: