-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: add NodeJS version #23
Conversation
Why not typeof bun === "undefined" |
Also we should check that esbuild plugin not broken with it |
Done, thanks! |
I tested on Windows side:
|
I added |
based i see this issue in my https://github.com/gramiojs/autoload too Bun just works fine |
did u try it? But for now it uses |
I know. |
Not yet |
How can we test with It that https://github.com/kravetsone/esbuild-plugin-autoload?tab=readme-ov-file#esbuild-usage the correct reference? Draft: await esbuild
.build({
target: "bun",
outdir: "out",
plugins: [{
name: 'elysia-autoload',
setup: autoload
}]
})
.then(console.log) |
Changed to use glob with async iteration with streams. Line 132 in a059f51
|
This logic can be restored: const paths: [path: string, exportName: string][] = [];
for await (const filePath of files) {
// ...
- if (types) paths.push([fullPath.replace(directoryPath, ""), importName]);
+ paths.push([fullPath.replace(directoryPath, ""), importName]);
}
+ if (failGlob && files.length === 0)
+ throw new Error(
+ `No matches found in ${directoryPath}. You can disable this error by setting the failGlob parameter to false in the options of autoload plugin`,
+ ); @kravetsone what do you think about? |
Idk why u drop it |
Because I changed the glob scan to async iteration with streams (https://bun.sh/docs/api/glob#quickstart) and the filepath list can't be collected. |
It is possible to add |
I add Because path with params should be connected in last way |
Ok, I restored the previous logic. |
is this PR ready for merge? |
Do we really need esbuild? I guess we can recommend It is also recommended in NodeJS documentation and it has support for import(".ts") |
love this PR also when elysia going to support node much better it really good |
I don't know if we should add a message error when using NodeJS and missing Note: on merging this PR, I would use the squash (cleaner history) instead of the merge.
NodeJS doesn't support
|
I mean that So if some TypeScript executor isn't support |
In the doc, |
Didn't understand what u mean by "we can use directly" What's we get with it? Seems like elysia application will be bundled or executed by |
Elysia is bundled with Some differences: https://dev.to/andreasbergstrom/simplify-typescript-builds-with-esbuild-and-skip-tsctsx-2124 Some references: |
yeah and classic user flow will be:
So why we need to execute |
When you start |
@kravetsone the error As probably Bun do, a loader needs to be used on entrypoint. So, I did a commit to remove Imo we can always use const file = await import(pathToFileURL(fullPath).href) instead of let file;
if (typeof Bun === "undefined")
? await import(pathToFileURL(fullPath).href)
: await import(fullPath) What do you think about? |
My comment: vitejs/vite#5370 (comment) |
Thanks for the work! Love it For final i guess we should not include any loaders to this library. Also |
Create a NodeJS version, so it can be used with https://github.com/elysiajs/node-adapter
Differences
fs.globSync
(it's introduced with NodeJS 22.0.0) instead ofBun.glob
fs.writeFileSync
insteadBun.write
Notes:
@types/node
is added as dev dependency because globSync (Node v22) isn't recognized.@types/bun
include@types/node
but is v20 (and not >=v22).After Update
@types/node
dependency version oven-sh/bun#13987 is merged,@types/node
dev dependency can be removed.TODO
.ts/.tsx
files needs to be transpiledFix #30