Skip to content

Commit

Permalink
remove styles npm/cdn bento packages (#36873)
Browse files Browse the repository at this point in the history
  • Loading branch information
kvchari committed Nov 10, 2021
1 parent 081a0b7 commit de4f57c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
25 changes: 4 additions & 21 deletions build-system/tasks/extension-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,11 +755,7 @@ async function getBentoBuildFilename(dir, name, mode, options) {
if (await fs.pathExists(`${dir}/${filename}`)) {
return filename;
}
const generatedSource = await generateBentoEntryPointSource(
name,
toExport,
options
);
const generatedSource = await generateBentoEntryPointSource(name, toExport);
const generatedFilename = `build/${filename}`;
await fs.outputFile(`${dir}/${generatedFilename}`, generatedSource);
return generatedFilename;
Expand All @@ -768,34 +764,21 @@ async function getBentoBuildFilename(dir, name, mode, options) {
/**
* @param {string} name
* @param {string} toExport
* @param {Object} options
* @return {Promise<string>}
*/
async function generateBentoEntryPointSource(name, toExport, options) {
const css = options.hasCss
? await fs.readFile(`build/css/${name}-${options.version}.css`, 'utf8')
: null;

async function generateBentoEntryPointSource(name, toExport) {
return dedent(`
import {BaseElement} from '../base-element';
function defineElement() {
const css = __css__;
if (css) {
const style = document.createElement('style');
style.textContent = css;
document.head.appendChild(style);
}
customElements.define(
__name__,
BaseElement.CustomElement(BaseElement)
);
}
${toExport ? 'export {defineElement};' : 'defineElement();'}
`)
.replace('__css__', JSON.stringify(css))
.replace('__name__', JSON.stringify(name));
`).replace('__name__', JSON.stringify(name));
}

/**
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/e2e/bento/social-share.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
async
src="https://cdn.ampproject.org/v0/bento-social-share-1.0.js"
></script>
<link rel="stylesheet" href="https://cdn.ampproject.org/v0/bento-social-share-1.0.css">
</head>
<body>
<h1>Social Share</h1>
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/e2e/bento/timeago.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
async
src="https://cdn.ampproject.org/v0/bento-timeago-1.0.js"
></script>
<link rel="stylesheet" href="https://cdn.ampproject.org/v0/bento-timeago-1.0.css">
</head>
<body>
<h1>Time Ago</h1>
Expand Down

0 comments on commit de4f57c

Please sign in to comment.