Add polyfill scripts to result.scripts (#1920)
* Add polyfill scripts to result.scripts * These scripts are bundled together now * Adds changeset
This commit is contained in:
parent
ae2cadd246
commit
2e0c790b3a
3 changed files with 13 additions and 4 deletions
5
.changeset/rare-cars-lick.md
Normal file
5
.changeset/rare-cars-lick.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fix Lit renderer built
|
|
@ -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) {
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
Loading…
Reference in a new issue