-
-
Notifications
You must be signed in to change notification settings - Fork 163
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: Migrate to ESM and use rollup for building #1067
Conversation
This commit includes several changes: - The package.json file has been updated to support ESM with the "type" field set to "module" and the "exports" field properly configured. - The build script in package.json has been changed to use tsup instead of tsc. - tsup has been added as a devDependency. - The tsconfig.json file has been simplified and updated for the new build process. - A new tsup.config.js file has been added to configure the tsup build. feat: Update build process and dependencies This commit updates the build process by replacing `tsc --watch` with `tsup --watch` in the `dev` script. It also removes the `tsp` section from `package.json` and deletes `tsup.config.js`. A new `tsup.config.ts` file is added which uses `fast-glob` and `node:fs/promises` to handle TypeScript compilation and file renaming. This is due to an issue with tsup's dts causing out of memory errors. Additionally, `@microsoft/api-extractor` and `fast-glob` are added as new devDependencies.
This commit fixes the dynamic imports in the typia.ts file by adding the .js extension. This ensures the correct files are imported when the script is run.
This commit replaces the usage of ts-node with tsx in the scripts section of both benchmark and test package.json files. The version of tsx used is 4.11.2. This change is expected to enhance the TypeScript execution environment.
The prepare script in package.json has been updated to include the 'typia patch' command. This change ensures that the typia patch is applied during the preparation phase of the project setup. feat: add typia patch to prepare script This commit modifies the 'prepare' script in the package.json file of the benchmark directory. The 'ts-patch install' command is now followed by 'typia patch'. This change ensures that typia patch is run during the preparation phase.
After that, I'm planning to create monorepo |
This PR does not resolve tree-shaking fully, but the bundle size is decreasing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, the transformer library like typia
must be built with CJS, when considering the standard transform function that will be provided by the Microsoft/TypeScript
.
Therefore, I'll try to change your commit, that can work properly with bundling, and also accomplish the bundling size diminishing. Thanks for considerations.
@samchon |
Will commit to your repo soon. Wait for maybe five to ten minutes please. Currently, I'm running test program, and it is working well even in the ESM. |
Thanks always |
Changed to CJS, but ESM still be supported following your idea. By the way, I'm sorry but I justed change something different with you:
Also, about the bundling size, I'll test it tomorrow. If you want to take it earlier, you can setup it with: npm i typia@next Anyway, as I'm not a frontend developer, not familiar with bundler story. By your contributions, I understood how important to support both CJS/ESM for disk space reason. Thanks for many ideas and contributions. |
Thank you for your quick response!!
If you are familer with it, that is fine!
I replaced |
Also, thank you for adding test for esm. |
As you told that you're planning to adjust monorepo, so that if |
Nice! Thanks One thing is the result of the build with rollup, but it has been combined into one mjs file! |
Oh, I looked up. |
Looking at the build results from your rollup, that one looks better with a smaller bundle size. Thanks. Thank you for reviewing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I will merge at morning.
What's changed
This commit includes several changes:
field set to "module" and This commit includes several changes:
field set to "module" and the "exports" field properly configured.
of tsc.
build process.
feat: Update build process and dependencies
This commit updates the build process by replacing
tsc --watch
withtsup --watch
in thedev
script. It also removes thetsp
sectionfrom
package.json
and deletestsup.config.js
.A new
tsup.config.ts
file is added which usesfast-glob
andnode:fs/promises
to handle TypeScript compilation and file renaming.This is due to an issue with tsup's dts causing out of memory errors.
Additionally,
@microsoft/api-extractor
andfast-glob
are added asnew devDependencies.Before submitting a Pull Request, please test your code.
Result
Here is the differnece of the bundle size
source code
Before
https://github.com/ryoppippi/typia-bundle-issue-repo/blob/8eb3cb8ec8dd8f8e9234aa2923cf352a73852c01/dist/index.js
After
https://github.com/ryoppippi/typia-bundle-issue-repo/blob/fb7bd4073cecafec84fa2e5f18656371e6df7cea/dist/index.js
======================
If you created a new feature, then create the unit test function, too.
Learn more about the CONTRIBUTINGthe "exports" field properly configured.
of tsc.
build process.
feat: Update build process and dependencies
This commit updates the build process by replacing
tsc --watch
withtsup --watch
in thedev
script. It also removes thetsp
sectionfrom
package.json
and deletestsup.config.js
.A new
tsup.config.ts
file is added which usesfast-glob
andnode:fs/promises
to handle TypeScript compilation and file renaming.This is due to an issue with tsup's dts causing out of memory errors.
Additionally,
@microsoft/api-extractor
andfast-glob
are added asnew devDependencies.Before submitting a Pull Request, please test your code.
If you created a new feature, then create the unit test function, too.
Learn more about the CONTRIBUTING