diff options
author | 2021-11-19 14:06:05 -0500 | |
---|---|---|
committer | 2021-11-19 14:06:05 -0500 | |
commit | 2e0c790b3af6fcd20ebcb2afd0284a8c663ada75 (patch) | |
tree | d6e30d7d6e2f4a0826dbf5c2b54c19e2f035cb15 | |
parent | ae2cadd2462ccfdfdbd84de8a1676202d7d2c60d (diff) | |
download | astro-2e0c790b3af6fcd20ebcb2afd0284a8c663ada75.tar.gz astro-2e0c790b3af6fcd20ebcb2afd0284a8c663ada75.tar.zst astro-2e0c790b3af6fcd20ebcb2afd0284a8c663ada75.zip |
Add polyfill scripts to result.scripts (#1920)
* Add polyfill scripts to result.scripts
* These scripts are bundled together now
* Adds changeset
-rw-r--r-- | .changeset/rare-cars-lick.md | 5 | ||||
-rw-r--r-- | packages/astro/src/runtime/server/index.ts | 8 | ||||
-rw-r--r-- | packages/astro/test/custom-elements.test.js | 4 |
3 files changed, 13 insertions, 4 deletions
diff --git a/.changeset/rare-cars-lick.md b/.changeset/rare-cars-lick.md new file mode 100644 index 000000000..2bdc132f4 --- /dev/null +++ b/.changeset/rare-cars-lick.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix Lit renderer built diff --git a/packages/astro/src/runtime/server/index.ts b/packages/astro/src/runtime/server/index.ts index 0b7a68a50..d140ac0da 100644 --- a/packages/astro/src/runtime/server/index.ts +++ b/packages/astro/src/runtime/server/index.ts @@ -224,8 +224,12 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr // This is used to add polyfill scripts to the page, if the renderer needs them. if (renderer?.polyfills?.length) { - let polyfillScripts = renderer.polyfills.map((src) => `<script type="module">import "${src}";</script>`).join(''); - html = html + polyfillScripts; + for(const src of renderer.polyfills) { + result.scripts.add({ + props: { type: 'module' }, + children: `import "${src}";`, + }); + } } if (!hydration) { diff --git a/packages/astro/test/custom-elements.test.js b/packages/astro/test/custom-elements.test.js index 4f442883b..177bc23f6 100644 --- a/packages/astro/test/custom-elements.test.js +++ b/packages/astro/test/custom-elements.test.js @@ -47,8 +47,8 @@ describe('Custom Elements', () => { expect($('my-element template[shadowroot=open]')).to.have.lengthOf(1); // Hydration - // test 3: Component and polyfill scripts included - expect($('script[type=module]')).to.have.lengthOf(2); + // test 3: Component and polyfill scripts bundled together + expect($('script[type=module]')).to.have.lengthOf(1); }); it('Polyfills are added even if not hydrating', async () => { |