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) => ``).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 () => {