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.
|
// This is used to add polyfill scripts to the page, if the renderer needs them.
|
||||||
if (renderer?.polyfills?.length) {
|
if (renderer?.polyfills?.length) {
|
||||||
let polyfillScripts = renderer.polyfills.map((src) => `<script type="module">import "${src}";</script>`).join('');
|
for(const src of renderer.polyfills) {
|
||||||
html = html + polyfillScripts;
|
result.scripts.add({
|
||||||
|
props: { type: 'module' },
|
||||||
|
children: `import "${src}";`,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hydration) {
|
if (!hydration) {
|
||||||
|
|
|
@ -47,8 +47,8 @@ describe('Custom Elements', () => {
|
||||||
expect($('my-element template[shadowroot=open]')).to.have.lengthOf(1);
|
expect($('my-element template[shadowroot=open]')).to.have.lengthOf(1);
|
||||||
|
|
||||||
// Hydration
|
// Hydration
|
||||||
// test 3: Component and polyfill scripts included
|
// test 3: Component and polyfill scripts bundled together
|
||||||
expect($('script[type=module]')).to.have.lengthOf(2);
|
expect($('script[type=module]')).to.have.lengthOf(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Polyfills are added even if not hydrating', async () => {
|
it('Polyfills are added even if not hydrating', async () => {
|
||||||
|
|
Loading…
Reference in a new issue