From 632f3f8e341d570eb7e85b5bfd88aafde0bc3d7a Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Tue, 23 Mar 2021 23:30:03 -0400 Subject: [PATCH] Reuse unminified babel config for faster dep-checks (#33453) Now that we're caching the `unminified` build, there's no reason to do _another_ babel compile just to dep-check. --- babel.config.js | 1 - build-system/babel-config/dep-check-config.js | 62 ------------------- build-system/tasks/dep-check.js | 2 +- build-system/test-configs/dep-check-config.js | 1 - 4 files changed, 1 insertion(+), 65 deletions(-) delete mode 100644 build-system/babel-config/dep-check-config.js diff --git a/babel.config.js b/babel.config.js index c829bae8ef02..3ec806d21754 100644 --- a/babel.config.js +++ b/babel.config.js @@ -34,7 +34,6 @@ const {cyan, yellow} = require('kleur/colors'); */ const babelTransforms = new Map([ ['babel-jest', 'getEmptyConfig'], - ['dep-check', 'getDepCheckConfig'], ['post-closure', 'getPostClosureConfig'], ['pre-closure', 'getPreClosureConfig'], ['test', 'getTestConfig'], diff --git a/build-system/babel-config/dep-check-config.js b/build-system/babel-config/dep-check-config.js deleted file mode 100644 index b8d8f386a4c1..000000000000 --- a/build-system/babel-config/dep-check-config.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright 2020 The AMP HTML Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS-IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict'; - -/** - * Gets the config for babel transforms run during `amp dep-check`. - * - * @return {!Object} - */ -function getDepCheckConfig() { - const reactJsxPlugin = [ - '@babel/plugin-transform-react-jsx', - { - pragma: 'Preact.createElement', - pragmaFrag: 'Preact.Fragment', - useSpread: true, - }, - ]; - const presetEnv = [ - '@babel/preset-env', - { - bugfixes: true, - modules: 'commonjs', - loose: true, - targets: {'browsers': ['Last 2 versions']}, - }, - ]; - const depCheckPlugins = [ - './build-system/babel-plugins/babel-plugin-transform-json-import', - './build-system/babel-plugins/babel-plugin-transform-json-configuration', - './build-system/babel-plugins/babel-plugin-transform-jss', - './build-system/babel-plugins/babel-plugin-transform-fix-leading-comments', - './build-system/babel-plugins/babel-plugin-transform-promise-resolve', - '@babel/plugin-transform-react-constant-elements', - '@babel/plugin-transform-classes', - '@babel/plugin-syntax-import-assertions', - reactJsxPlugin, - ]; - const depCheckPresets = [presetEnv]; - return { - compact: false, - plugins: depCheckPlugins, - presets: depCheckPresets, - }; -} - -module.exports = { - getDepCheckConfig, -}; diff --git a/build-system/tasks/dep-check.js b/build-system/tasks/dep-check.js index 1c6bb9beb3a3..17be9c070eea 100644 --- a/build-system/tasks/dep-check.js +++ b/build-system/tasks/dep-check.js @@ -190,7 +190,7 @@ async function getEntryPointModule() { * @return {!Promise} */ async function getModuleGraph(entryPointModule) { - const plugin = getEsbuildBabelPlugin('dep-check', /* enableCache */ true); + const plugin = getEsbuildBabelPlugin('unminified', /* enableCache */ true); const result = await esbuild.build({ stdin: { contents: entryPointModule, diff --git a/build-system/test-configs/dep-check-config.js b/build-system/test-configs/dep-check-config.js index 8baece32eaf1..9d99ac31fff5 100644 --- a/build-system/test-configs/dep-check-config.js +++ b/build-system/test-configs/dep-check-config.js @@ -433,7 +433,6 @@ exports.rules = [ 'src/polyfills/fetch.js->src/utils/bytes.js', 'src/polyfills/intersection-observer.js->src/polyfillstub/intersection-observer-stub.js', 'src/polyfills/resize-observer.js->src/polyfillstub/resize-observer-stub.js', - 'src/polyfills/promise.js->node_modules/promise-pjs/promise.js', 'src/polyfills/custom-elements.js->src/resolved-promise.js', ], },