Skip to content

Commit

Permalink
🏗️ Simplify enabling npm bundle for components (#34262)
Browse files Browse the repository at this point in the history
* Simplify enabling npm bundle

* %s/const/let/
  • Loading branch information
rcebulko committed May 7, 2021
1 parent 2e762f0 commit 9372b58
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 61 deletions.
70 changes: 10 additions & 60 deletions build-system/compile/bundles.config.extensions.json
Expand Up @@ -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"},
Expand Down Expand Up @@ -150,12 +145,7 @@
"version": "1.0",
"latestVersion": "0.1",
"options": {
"npm": {
"component.js": {
"preact": "component-preact.js",
"react": "component-react.js"
}
}
"npm": true
}
},
{
Expand All @@ -168,12 +158,7 @@
"version": "1.0",
"latestVersion": "0.1",
"options": {
"npm": {
"component.js": {
"preact": "component-preact.js",
"react": "component-react.js"
}
}
"npm": true
}
},
{
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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"},
Expand All @@ -318,12 +293,7 @@
"latestVersion": "0.1",
"options": {
"hasCss": true,
"npm": {
"component.js": {
"preact": "component-preact.js",
"react": "component-react.js"
}
}
"npm": true
}
},
{
Expand Down Expand Up @@ -351,12 +321,7 @@
"latestVersion": "0.1",
"options": {
"hasCss": true,
"npm": {
"component.js": {
"preact": "component-preact.js",
"react": "component-react.js"
}
}
"npm": true
}
},
{
Expand Down Expand Up @@ -485,12 +450,7 @@
"latestVersion": "0.1",
"options": {
"hasCss": true,
"npm": {
"component.js": {
"preact": "component-preact.js",
"react": "component-react.js"
}
}
"npm": true
}
},
{
Expand Down Expand Up @@ -652,12 +612,7 @@
"version": "1.0",
"latestVersion": "0.1",
"options": {
"npm": {
"component.js": {
"preact": "component-preact.js",
"react": "component-react.js"
}
}
"npm": true
}
},
{
Expand Down Expand Up @@ -739,12 +694,7 @@
"latestVersion": "0.1",
"options": {
"hasCss": true,
"npm": {
"component.js": {
"preact": "component-preact.js",
"react": "component-react.js"
}
}
"npm": true
}
}
]
11 changes: 10 additions & 1 deletion build-system/tasks/extension-helpers.js
Expand Up @@ -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];
Expand Down

0 comments on commit 9372b58

Please sign in to comment.