From 392f7d223ab1d4449fd96307a90c2af60c68aab4 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 21 Mar 2024 15:15:55 -0400 Subject: [PATCH] chore: fix treeshaking check (#10862) --- packages/svelte/scripts/check-treeshakeability.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/svelte/scripts/check-treeshakeability.js b/packages/svelte/scripts/check-treeshakeability.js index a6164c462b..21f33ab6f0 100644 --- a/packages/svelte/scripts/check-treeshakeability.js +++ b/packages/svelte/scripts/check-treeshakeability.js @@ -12,6 +12,15 @@ async function bundle_code(entry) { virtual({ __entry__: entry }), + { + name: 'resolve-svelte', + resolveId(importee) { + if (importee.startsWith('svelte')) { + const entry = pkg.exports[importee.replace('svelte', '.')]; + return path.resolve(entry.browser ?? entry.default); + } + } + }, nodeResolve({ exportConditions: ['production', 'import', 'browser', 'default'] }) @@ -99,6 +108,7 @@ const without_hydration = await bundle_code( { filename: 'App.svelte' } ).js.code ); + if (!without_hydration.includes('current_hydration_fragment')) { // eslint-disable-next-line no-console console.error(`✅ Hydration code treeshakeable`);