mirror of
https://github.com/withastro/astro.git
synced 2025-01-27 22:19:04 -05:00
Retain client scripts in content cache (#11170)
* Retain client scripts in content cache * Add test
This commit is contained in:
parent
ff8004f6a7
commit
ba20c718a4
3 changed files with 21 additions and 0 deletions
5
.changeset/wicked-dragons-draw.md
Normal file
5
.changeset/wicked-dragons-draw.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Retain client scripts in content cache
|
|
@ -255,6 +255,7 @@ function vitePluginContent(
|
|||
...oldManifest.clientEntries,
|
||||
...internals.discoveredHydratedComponents.keys(),
|
||||
...internals.discoveredClientOnlyComponents.keys(),
|
||||
...internals.discoveredScripts
|
||||
]);
|
||||
// Likewise, these are server modules that might not be referenced
|
||||
// once the cached items are excluded from the build process
|
||||
|
|
|
@ -136,6 +136,21 @@ if (!isWindows) {
|
|||
const files = await fixture.readdir('');
|
||||
assert.equal(files.includes('chunks'), false, 'chunks folder removed');
|
||||
});
|
||||
|
||||
it('hoisted script is built', async () => {
|
||||
const html = await fixture.readFile('/launch-week-component-scripts/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
const allScripts = $('head > script[type="module"]');
|
||||
assert.ok(allScripts.length > 0);
|
||||
|
||||
// Includes hoisted script
|
||||
assert.notEqual(
|
||||
[...allScripts].find((script) => $(script).attr('src')?.includes('/_astro/WithScripts')),
|
||||
undefined,
|
||||
'hoisted script missing from head.'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue