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
gulp build: support esm #32926
Conversation
@@ -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', |
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.
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).
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.
ah! that is different. that is about literally outputting esmodules, as opposed to what we call "esm build", which simply reduces transpilation.
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.
For reference, the unminified dist build goes from 799K
to 770K
with the --esm
flag. I'll further reduce it right now.
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.
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 :)
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.
Aha, I now see. This gets babel
to do something different because of argv.esm
, while esbuild
does its regular thing.
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.
LGTM!
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.