Skip to content

Commit 392f7d2

Browse files
authored
chore: fix treeshaking check (#10862)
1 parent aec4958 commit 392f7d2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/svelte/scripts/check-treeshakeability.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ async function bundle_code(entry) {
1212
virtual({
1313
__entry__: entry
1414
}),
15+
{
16+
name: 'resolve-svelte',
17+
resolveId(importee) {
18+
if (importee.startsWith('svelte')) {
19+
const entry = pkg.exports[importee.replace('svelte', '.')];
20+
return path.resolve(entry.browser ?? entry.default);
21+
}
22+
}
23+
},
1524
nodeResolve({
1625
exportConditions: ['production', 'import', 'browser', 'default']
1726
})
@@ -99,6 +108,7 @@ const without_hydration = await bundle_code(
99108
{ filename: 'App.svelte' }
100109
).js.code
101110
);
111+
102112
if (!without_hydration.includes('current_hydration_fragment')) {
103113
// eslint-disable-next-line no-console
104114
console.error(`✅ Hydration code treeshakeable`);

0 commit comments

Comments
 (0)