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

build: fix esBuild only emitting esm format #540

Closed
wants to merge 3 commits into from

Conversation

WenheLI
Copy link
Collaborator

@WenheLI WenheLI commented Sep 1, 2020

This PR fixes the #520 which only generates esm format for nodejs.
To make a temporary workaround, I imported babel to transform esm to cjs.
For the build performance, despite using esbuild + babel, the speed is still out-perform tsc:

tsc esBuild+Babel esBuild
11.0s 2.8s 1.8s

Note: since esbuild omits interface in ts, we need to operate a regular build prior to dev-build to avoid missing interface only files.

In the long run, I will add try to add the support of esm2cjs transforming for esBuild to avoid the babel overhead.

"clean": "rm -rf ./dist && rm -rf tsconfig.tsbuildinfo",
"dev-compile": "esbuild ./src/*.ts ./src/**/*.ts --tsconfig=tsconfig.json --outdir=dist && sh setup.sh",
"dev-compile": "esbuild ./src/*.ts ./src/**/*.ts --tsconfig=tsconfig.json --outdir=dist && npm run dev-trans && sh setup.sh",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we have a universal script for wrapping the dev-trans and dev-compile?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, this dev-trans is just a temporary workaround. We will get rid of it eventually. In this case, I don't think we need to have a universal script.

@FeelyChau FeelyChau added the build CI/CD, and build stuffs label Sep 3, 2020
@yorkie
Copy link
Member

yorkie commented Sep 5, 2020

@WenheLI The current script looks too complicated, may I ask you to simplify this?

@WenheLI
Copy link
Collaborator Author

WenheLI commented Sep 7, 2020

@WenheLI The current script looks too complicated, may I ask you to simplify this?

esBuild now support directly exporting packages to cjs, which means we do not need to manually transform it using babel.
See evanw/esbuild#109 (comment), I will update the esBuild once it is officially launched.

@yorkie
Copy link
Member

yorkie commented Sep 7, 2020

@WenheLI So the esbuild version update is the only change to fix #520?

@WenheLI
Copy link
Collaborator Author

WenheLI commented Sep 7, 2020

@WenheLI So the esbuild version update is the only change to fix #520?

Yep, we only need to wait for the official launch.

@WenheLI WenheLI closed this Sep 7, 2020
@FeelyChau FeelyChau deleted the fix/fix-esm-module branch February 24, 2021 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build CI/CD, and build stuffs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants