-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
🏗♻️ Consolidate all babel
configs into babel.config.js
#27576
🏗♻️ Consolidate all babel
configs into babel.config.js
#27576
Conversation
@jridgewell @erwinmombay @kristoferbaxter I tried reverse engineering this by printing the configurations before / after refactor, but there were too many files for which to inspect the diffs. It will be significantly easier if you folks took a look at this file and pointed out things that need to be changed. |
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.
Given how long I spent trying to parse a lot of this code, I'm impressed at how much you were able to consolidate. That said, is there any good way for use to validate these changes to ensure we didn't miss some small thing? For instance, if we were to run each of the build commands/babel configs, would we be able to diff the outputs and verify that we got the exact same results, or are the changes expected to impact the output in some way?
See #27576 (comment) for how we can make sure the same babel transforms are applied. Also, re: code output, the stated goal (in the description) is that nothing should change. We'll eventually get there, after multiple rounds of review and testing. |
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'm not certain I get this PR yet.
Everything related to Babel is in one place, but the callers
are strings that execute other functions, which return static Object literals?
Would it make more sense to make the babel.config.js
file lean (contains imports for these callers from a subdirectory inside babel
or similar) and delegate the functionality with a prescribed lifecycle?
No, all the
Having |
@kristoferbaxter Can you take a look at the current WIP |
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.
🙌
On the nature of a single file versus many, I'm not too strongly positioned however it might be worth considering this structure.
Each of these files can export an object for the different lifecycles they support. These lifecycle names and meanings can be defined in a class that all exports used by Additionally, the names of the "caller" is a nice contract for storing them in a Map inside note: this is pseudo-code. import {singlePassConfiguration} from 'babel-configurations/single-pass';
const configOptions = new Map({
'single-pass': singlePassConfiguration,
...
})
export function execute(caller) {
if (configOptions.has(caller)) {
const configuration = configOptions.get(caller);
...
}
} |
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.
Configs look like they should be accurate for esm and dist afaik.
@kristoferbaxter Thanks for the excellent PR feedback! I've incorporated all your comments and marked this PR as ready for review. Now begins the task of running "before" and "after" builds of all kinds and ironing out config diffs. I'll post an update once this is done, and report if I find any problems. |
Awesome, I should be able to take another look at this first thing tomorrow. |
Hey @estherkim, these files were changed:
|
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.
This is a significant improvement to readability. Thank you for doing this!
Thanks for the patient reviews, everyone. We are now in a working state with an all-green Travis build. I did a before/after comparison of the entire For the remaining callers of babel transforms like This PR is now ready to merge. |
babel
configuration into babel.config.js
babel
configs into babel.config.js
…mpproject#27576)" This reverts commit f801a93.
* Revert "🏗🐛 Fix babel plugin tests and run them for babel config chan… (ampproject#27664)" This reverts commit 39dac8e. * Revert "🏗♻️ Consolidate all `babel` configs into `babel.config.js` (ampproject#27576)" This reverts commit f801a93.
…mpproject#27576)" This reverts commit f801a93.
…mpproject#27576)" This reverts commit f801a93.
…mpproject#27576)" This reverts commit f801a93.
…mpproject#27576)" This reverts commit f801a93.
…mpproject#27576)" This reverts commit f801a93.
…mpproject#27576)" This reverts commit f801a93.
…mpproject#27576)" This reverts commit f801a93.
…mpproject#27576)" This reverts commit f801a93.
…mpproject#27576)" This reverts commit f801a93.
…mpproject#27576)" This reverts commit f801a93.
…mpproject#27576)" This reverts commit f801a93.
…mpproject#27576)" This reverts commit f801a93.
…mpproject#27576)" This reverts commit f801a93.
…mpproject#27576)" This reverts commit f801a93.
* temp * temp * add conditional to the css removal * add travis entry * add esm-tests.js file * minor fix to add coverage * remove compiled to test * add compiled back in * Revert "🏗♻️ Consolidate all `babel` configs into `babel.config.js` (#27576)" This reverts commit f801a93. * temp * temp * reset this to be close to master * temp * temp * temp * temp * for non dev builds (compiled, rtv) take into account the module build for regex replace * temp * remove debuggers * temp * apply recs * remove runner.js * apply recs * add --esm flag to integration run * download dist output as we need f.js/integration.js from dist nomodule * allow cors explicitly for mjs files GET requests * add flag to overwrite when unzipping * fix test type inference * apply recs
* temp * temp * add conditional to the css removal * add travis entry * add esm-tests.js file * minor fix to add coverage * remove compiled to test * add compiled back in * Revert "🏗♻️ Consolidate all `babel` configs into `babel.config.js` (ampproject#27576)" This reverts commit f801a93. * temp * temp * reset this to be close to master * temp * temp * temp * temp * for non dev builds (compiled, rtv) take into account the module build for regex replace * temp * remove debuggers * temp * apply recs * remove runner.js * apply recs * add --esm flag to integration run * download dist output as we need f.js/integration.js from dist nomodule * allow cors explicitly for mjs files GET requests * add flag to overwrite when unzipping * fix test type inference * apply recs
The compilation tasks and checks in the
amphtml
toolchain applybabel
transforms to code in a variety of ways. Today, the configs for these transforms are peppered acrossbuild-system/
, resulting in a hard-to-maintain mess of config code.#27117 was filed to address this problem, and #27161 took a first stab at fixing this. This PR picks up from there, and does the following:
build-system/compile/build.conf.js
and deletes the filebabel
,babelify
, andgulp-babel
invocations inbuild-system/babel-config/*-config.js
caller
identifier to every invocation sitebabel.config.js
to return the config that corresponds to thecaller
With this PR, all
babel
configs will live inbuild-system/babel-config/
, while the resulting runtime binaries remain unchanged.Fixes #27117
Closes #27161