From 9372b58727c3f9d51ffcbc1d5da67039640ec9b2 Mon Sep 17 00:00:00 2001 From: Ryan Cebulko Date: Fri, 7 May 2021 09:16:57 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=20Simplify=20enabling=20n?= =?UTF-8?q?pm=20bundle=20for=20components=20(#34262)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Simplify enabling npm bundle * %s/const/let/ --- .../compile/bundles.config.extensions.json | 70 +++---------------- build-system/tasks/extension-helpers.js | 11 ++- 2 files changed, 20 insertions(+), 61 deletions(-) diff --git a/build-system/compile/bundles.config.extensions.json b/build-system/compile/bundles.config.extensions.json index c9c1be95a07b..48874bd0d761 100644 --- a/build-system/compile/bundles.config.extensions.json +++ b/build-system/compile/bundles.config.extensions.json @@ -32,12 +32,7 @@ "latestVersion": "0.1", "options": { "hasCss": true, - "npm": { - "component.js": { - "preact": "component-preact.js", - "react": "component-react.js" - } - } + "npm": true } }, {"name": "amp-action-macro", "version": "0.1", "latestVersion": "0.1"}, @@ -150,12 +145,7 @@ "version": "1.0", "latestVersion": "0.1", "options": { - "npm": { - "component.js": { - "preact": "component-preact.js", - "react": "component-react.js" - } - } + "npm": true } }, { @@ -168,12 +158,7 @@ "version": "1.0", "latestVersion": "0.1", "options": { - "npm": { - "component.js": { - "preact": "component-preact.js", - "react": "component-react.js" - } - } + "npm": true } }, { @@ -211,12 +196,7 @@ "latestVersion": "0.1", "options": { "hasCss": true, - "npm": { - "component.js": { - "preact": "component-preact.js", - "react": "component-react.js" - } - } + "npm": true } }, {"name": "amp-font", "version": "0.1", "latestVersion": "0.1"}, @@ -297,12 +277,7 @@ "options": { "hasCss": true, "cssBinaries": ["amp-inline-gallery-pagination"], - "npm": { - "component.js": { - "preact": "component-preact.js", - "react": "component-react.js" - } - } + "npm": true } }, {"name": "amp-inputmask", "version": "0.1", "latestVersion": "0.1"}, @@ -318,12 +293,7 @@ "latestVersion": "0.1", "options": { "hasCss": true, - "npm": { - "component.js": { - "preact": "component-preact.js", - "react": "component-react.js" - } - } + "npm": true } }, { @@ -351,12 +321,7 @@ "latestVersion": "0.1", "options": { "hasCss": true, - "npm": { - "component.js": { - "preact": "component-preact.js", - "react": "component-react.js" - } - } + "npm": true } }, { @@ -485,12 +450,7 @@ "latestVersion": "0.1", "options": { "hasCss": true, - "npm": { - "component.js": { - "preact": "component-preact.js", - "react": "component-react.js" - } - } + "npm": true } }, { @@ -652,12 +612,7 @@ "version": "1.0", "latestVersion": "0.1", "options": { - "npm": { - "component.js": { - "preact": "component-preact.js", - "react": "component-react.js" - } - } + "npm": true } }, { @@ -739,12 +694,7 @@ "latestVersion": "0.1", "options": { "hasCss": true, - "npm": { - "component.js": { - "preact": "component-preact.js", - "react": "component-react.js" - } - } + "npm": true } } ] diff --git a/build-system/tasks/extension-helpers.js b/build-system/tasks/extension-helpers.js index a8d0c24141ef..f24c02d71b75 100644 --- a/build-system/tasks/extension-helpers.js +++ b/build-system/tasks/extension-helpers.js @@ -565,7 +565,16 @@ function buildExtensionCss(extDir, name, version, options) { * @return {!Promise} */ function buildNpmBinaries(extDir, options) { - const {npm} = options; + let {npm} = options; + if (npm === true) { + // Default to the standard/expected entrypoint + npm = { + 'component.js': { + 'preact': 'component-preact.js', + 'react': 'component-react.js', + }, + }; + } const keys = Object.keys(npm); const promises = keys.flatMap((entryPoint) => { const {preact, react} = npm[entryPoint];