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

gulp build: support esm #32926

Merged
merged 2 commits into from Feb 25, 2021
Merged

gulp build: support esm #32926

merged 2 commits into from Feb 25, 2021

Conversation

samouri
Copy link
Member

@samouri samouri commented Feb 25, 2021

summary

Allow gulp build to process --esm mode. This aligns it with dist build's definition of esm mode (less transpilation, and fewer polyfills).

Note: esbuild still outputs an IIFE and not esm. this is intentional and controlled via the format option.

@samouri samouri self-assigned this Feb 25, 2021
@samouri samouri marked this pull request as ready for review February 25, 2021 20:03
@samouri samouri requested review from danielrozenberg and rsimha and removed request for rileyajones February 25, 2021 20:03
@@ -100,6 +100,7 @@ build.flags = {
coverage: ' Adds code coverage instrumentation to JS files using istanbul.',
version_override: ' Overrides the version written to AMP_CONFIG',
watch: ' Watches for changes in files, re-builds when detected',
esm: ' Do not transpile down to ES5',
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to consume argv.esm in the call to esbuild, right? IIRC, @jridgewell tried doing this in e1c028c (#32699) and had to revert in 85ab0b8 (#32699).

Copy link
Member Author

@samouri samouri Feb 25, 2021

Choose a reason for hiding this comment

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

ah! that is different. that is about literally outputting esmodules, as opposed to what we call "esm build", which simply reduces transpilation.

Copy link
Member Author

@samouri samouri Feb 25, 2021

Choose a reason for hiding this comment

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

For reference, the unminified dist build goes from 799K to 770K with the --esm flag. I'll further reduce it right now.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've reduced the transpilation further to align better with what we do in --compiled mode. Now it is down to 754K, and should be even faster to run :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Aha, I now see. This gets babel to do something different because of argv.esm, while esbuild does its regular thing.

Copy link
Contributor

@rsimha rsimha left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants