From 49cc9e3ffb9088c2616a6e6f9b07fe67e8a29d74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20I=C3=9Fbr=C3=BCcker?= Date: Sat, 23 Aug 2025 19:56:10 +0200 Subject: [PATCH] fix: make emitCss: false work with Svelte 5 --- index.js | 2 ++ test/index.js | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/index.js b/index.js index 6e32b7e..c59b574 100644 --- a/index.js +++ b/index.js @@ -55,6 +55,8 @@ module.exports = function (options = {}) { ); } compilerOptions.css = cssOptionValue; + } else if (majorVersion > 4) { + compilerOptions.css = 'injected'; } return { diff --git a/test/index.js b/test/index.js index e485327..5c96695 100644 --- a/test/index.js +++ b/test/index.js @@ -114,6 +114,25 @@ test('respects `sourcemapExcludeSources` Rollup option', async () => { assert.is(map.sourcesContent, null); }); +test('injects CSS with `emitCss: false', async () => { + const p = plugin({emitCss: false}); + + const transformed = await p.transform( + ` +

Hello!

+ + + `, + 'test.svelte' + ); + + assert.ok(transformed.code.includes('color:red')); +}); + test('squelches "unused CSS" warnings if `emitCss: false`', () => { const p = plugin({ emitCss: false,