From 853c8da500d35e5aef0a202de3cc830a10dcf95f Mon Sep 17 00:00:00 2001 From: Jake Fried Date: Wed, 7 Jul 2021 22:45:31 -0400 Subject: [PATCH] remove amp-mode-transform --- build-system/babel-config/minified-config.js | 6 -- .../babel-config/pre-closure-config.js | 9 --- .../index.js | 73 ------------------- .../no-transform/input.js | 24 ------ .../no-transform/options.json | 5 -- .../no-transform/output.js | 23 ------ .../transform-assertions/nomodule/input.js | 28 ------- .../nomodule/options.json | 11 --- .../transform-assertions/nomodule/output.mjs | 26 ------- .../transform-assertions/transform/input.js | 28 ------- .../transform/options.json | 6 -- .../transform-assertions/transform/output.mjs | 26 ------- .../test/index.js | 19 ----- 13 files changed, 284 deletions(-) delete mode 100644 build-system/babel-plugins/babel-plugin-amp-mode-transformer/index.js delete mode 100644 build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/no-transform/input.js delete mode 100644 build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/no-transform/options.json delete mode 100644 build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/no-transform/output.js delete mode 100644 build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/nomodule/input.js delete mode 100644 build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/nomodule/options.json delete mode 100644 build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/nomodule/output.mjs delete mode 100644 build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/transform/input.js delete mode 100644 build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/transform/options.json delete mode 100644 build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/transform/output.mjs delete mode 100644 build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/index.js diff --git a/build-system/babel-config/minified-config.js b/build-system/babel-config/minified-config.js index aa2d3ad167e7..fd2d015432e6 100644 --- a/build-system/babel-config/minified-config.js +++ b/build-system/babel-config/minified-config.js @@ -67,12 +67,6 @@ function getMinifiedConfig() { argv.fortesting ? null : './build-system/babel-plugins/babel-plugin-transform-json-configuration', - argv.fortesting - ? null - : [ - './build-system/babel-plugins/babel-plugin-amp-mode-transformer', - {isEsmBuild: !!argv.esm}, - ], ].filter(Boolean); const presetEnv = [ '@babel/preset-env', diff --git a/build-system/babel-config/pre-closure-config.js b/build-system/babel-config/pre-closure-config.js index f0741814ae75..3f532e924ccd 100644 --- a/build-system/babel-config/pre-closure-config.js +++ b/build-system/babel-config/pre-closure-config.js @@ -26,9 +26,6 @@ const {getReplacePlugin} = require('./helpers'); */ function getPreClosureConfig() { const isCheckTypes = argv._.includes('check-types'); - const testTasks = ['e2e', 'integration', 'visual-diff']; - const isTestTask = testTasks.some((task) => argv._.includes(task)); - const isFortesting = argv.fortesting || isTestTask; const reactJsxPlugin = [ '@babel/plugin-transform-react-jsx', @@ -76,12 +73,6 @@ function getPreClosureConfig() { !isCheckTypes ? './build-system/babel-plugins/babel-plugin-transform-json-configuration' : null, - !(isFortesting || isCheckTypes) - ? [ - './build-system/babel-plugins/babel-plugin-amp-mode-transformer', - {isEsmBuild: !!argv.esm}, - ] - : null, ].filter(Boolean); const presetEnv = [ '@babel/preset-env', diff --git a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/index.js b/build-system/babel-plugins/babel-plugin-amp-mode-transformer/index.js deleted file mode 100644 index 1b584a5f02ec..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/index.js +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright 2018 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. - */ - -/** - * Changes the values of getMode().test, getMode().localDev to false - * and getMode().localDev to true. - * @param {Object} babelTypes - */ -const {dirname, join, relative, resolve} = require('path').posix; - -let shouldResolveDevelopmentMode = true; - -// This plugin is not executed when AMP is building resources in isForTesting mode. -module.exports = function ({types: t}) { - let getModeFound = false; - return { - pre() { - const {isEsmBuild = true} = this.opts; - // Only apply the development resolution when building module output. - // This is due to the module output only applying to AMP Caches. - shouldResolveDevelopmentMode = isEsmBuild; - }, - visitor: { - ImportDeclaration({node}, state) { - const {source, specifiers} = node; - if (!source.value.endsWith('/mode')) { - return; - } - specifiers.forEach((specifier) => { - if (specifier.imported && specifier.imported.name === 'getMode') { - const filepath = relative( - join(__dirname, '../../../'), - resolve(dirname(state.file.opts.filename), source.value) - ); - if (filepath.endsWith('src/mode')) { - getModeFound = true; - } - } - }); - }, - MemberExpression(path) { - if (!getModeFound) { - return; - } - - const {node} = path; - const {object: obj, property} = node; - const {callee} = obj; - if (callee && callee.name === 'getMode') { - if (property.name === 'test' || property.name === 'localDev') { - path.replaceWith(t.booleanLiteral(false)); - } - if (shouldResolveDevelopmentMode && property.name === 'development') { - path.replaceWith(t.booleanLiteral(false)); - } - } - }, - }, - }; -}; diff --git a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/no-transform/input.js b/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/no-transform/input.js deleted file mode 100644 index d6bbdd24f835..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/no-transform/input.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright 2018 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. - */ - -const test = getMode().test; -const localDev = getMode().localDev; -const minified = getMode().minified; -const development = getMode().development; - -function getMode() { - return {}; -} diff --git a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/no-transform/options.json b/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/no-transform/options.json deleted file mode 100644 index 3ebeb6374116..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/no-transform/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "plugins": [ - "../../../.." - ] -} diff --git a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/no-transform/output.js b/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/no-transform/output.js deleted file mode 100644 index 5e7f97a5f3db..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/no-transform/output.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright 2018 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. - */ -const test = getMode().test; -const localDev = getMode().localDev; -const minified = getMode().minified; -const development = getMode().development; - -function getMode() { - return {}; -} diff --git a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/nomodule/input.js b/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/nomodule/input.js deleted file mode 100644 index 094cba5ba364..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/nomodule/input.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright 2018 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. - */ - -import { getMode } from '../../../../../../../src/mode'; - -const test = getMode().test; -const localDev = getMode().localDev; -const minified = getMode().minified; -const development = getMode().development; - -function foo() { - if (getMode().development == false) { - return false; - } -} diff --git a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/nomodule/options.json b/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/nomodule/options.json deleted file mode 100644 index c08413593a14..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/nomodule/options.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "plugins": [ - [ - "../../../..", - { - "isEsmBuild": false - } - ] - ], - "sourceType": "module" -} diff --git a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/nomodule/output.mjs b/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/nomodule/output.mjs deleted file mode 100644 index 3ad2689e8c47..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/nomodule/output.mjs +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright 2018 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. - */ -import { getMode } from '../../../../../../../src/mode'; -const test = false; -const localDev = false; -const minified = true; -const development = getMode().development; - -function foo() { - if (getMode().development == false) { - return false; - } -} diff --git a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/transform/input.js b/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/transform/input.js deleted file mode 100644 index 094cba5ba364..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/transform/input.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright 2018 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. - */ - -import { getMode } from '../../../../../../../src/mode'; - -const test = getMode().test; -const localDev = getMode().localDev; -const minified = getMode().minified; -const development = getMode().development; - -function foo() { - if (getMode().development == false) { - return false; - } -} diff --git a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/transform/options.json b/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/transform/options.json deleted file mode 100644 index 239cccc175ab..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/transform/options.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "plugins": [ - "../../../.." - ], - "sourceType": "module" -} diff --git a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/transform/output.mjs b/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/transform/output.mjs deleted file mode 100644 index 73c919c2189b..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/fixtures/transform-assertions/transform/output.mjs +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright 2018 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. - */ -import { getMode } from '../../../../../../../src/mode'; -const test = false; -const localDev = false; -const minified = true; -const development = false; - -function foo() { - if (false == false) { - return false; - } -} diff --git a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/index.js b/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/index.js deleted file mode 100644 index 7b6d7376a749..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-mode-transformer/test/index.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2018 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. - */ - -const runner = require('@babel/helper-plugin-test-runner').default; - -runner(__dirname);