Skip to content
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

ESM first #1468

Open
ryoppippi opened this issue Jan 27, 2025 · 6 comments
Open

ESM first #1468

ryoppippi opened this issue Jan 27, 2025 · 6 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ryoppippi
Copy link
Contributor

Today, js is becoming esm first: esm works in browsers and has advantages for tree-shaking.
So we want to replace the parts of various scripts where commonjs are used with esm. We still intend to include commonjs in the build.
I'll work on it if you want.

@samchon
Copy link
Owner

samchon commented Jan 27, 2025

The transformer (typia/lib/transform) must keep the CJS because tsc is using it.

Also, typia must be both CJS and ESM compatible, due to main purpose of typia is supporting nestia, especially for A.I. chatbot.

If you can keep two things without break change which requires major version update, it is okay to start.

@samchon samchon added enhancement New feature or request good first issue Good for newcomers labels Jan 27, 2025
@ryoppippi
Copy link
Contributor Author

@samchon okay got is
we must include cjs, for transformer for sure.

@samchon
Copy link
Owner

samchon commented Jan 27, 2025

Also, keep the CLI (npx typia setup) command as CJS please.

It is imported by nestia and the nestia's basic library NestJS is still using CJS too.

@ryoppippi
Copy link
Contributor Author

Nice! got it!
Actually, I keep all cjs build, but the primary script will be esm

BTW, in the future we can deprecate CJS because of this flag https://nodejs.org/en/blog/announcements/v22-release-announce#support-requireing-synchronous-esm-graphs

@samchon
Copy link
Owner

samchon commented Jan 27, 2025

I'll deprecate CJS when TypeScript and NestJS do it.

@ryoppippi
Copy link
Contributor Author

https://antfu.me/posts/move-on-to-esm-only
FYI

Actually I already finished moving to ESM first. I'll investigate whether test works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants