From f05a504f31b6cdc9eebc4262ce99cfc8e05ddc13 Mon Sep 17 00:00:00 2001 From: gucheen Date: Mon, 26 Jun 2023 11:29:00 +0800 Subject: [PATCH 1/5] feat: compilerOptions.css as a boolean is deprecated. Use 'external' instead of false. --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 1dc1838..85bc2e0 100644 --- a/index.js +++ b/index.js @@ -44,10 +44,10 @@ module.exports = function (options = {}) { if (emitCss) { if (compilerOptions.css) { console.warn( - `${PREFIX} Forcing \`"compilerOptions.css": false\` because "emitCss" was truthy.` + `${PREFIX} Forcing \`"compilerOptions.css": "external"\` because "emitCss" was truthy.` ); } - compilerOptions.css = false; + compilerOptions.css = 'external'; } return { From 4a71313175454a6d45d2857861f866fc0679fa6c Mon Sep 17 00:00:00 2001 From: gucheen Date: Mon, 26 Jun 2023 11:56:06 +0800 Subject: [PATCH 2/5] feat: css option value by svelte compiler version --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 85bc2e0..765d7ef 100644 --- a/index.js +++ b/index.js @@ -42,12 +42,14 @@ module.exports = function (options = {}) { const { onwarn, emitCss = true } = rest; if (emitCss) { + const [majorVer, minorVer] = VERSION.split('.'); + const cssOptionValue = majorVer > 3 || (majorVer >= 2 && minorVer >= 53) ? 'external' : true; if (compilerOptions.css) { console.warn( - `${PREFIX} Forcing \`"compilerOptions.css": "external"\` because "emitCss" was truthy.` + `${PREFIX} Forcing \`"compilerOptions.css": ${typeof cssOptionValue === 'string' ? `"${cssOptionValue}"` : cssOptionValue}\` because "emitCss" was truthy.` ); } - compilerOptions.css = 'external'; + compilerOptions.css = cssOptionValue; } return { From baeb7116e85bd8a8b89609d40dbf28c28d0684e2 Mon Sep 17 00:00:00 2001 From: gucheen Date: Mon, 26 Jun 2023 11:58:42 +0800 Subject: [PATCH 3/5] fix: major version compare --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 765d7ef..226cad3 100644 --- a/index.js +++ b/index.js @@ -43,7 +43,7 @@ module.exports = function (options = {}) { if (emitCss) { const [majorVer, minorVer] = VERSION.split('.'); - const cssOptionValue = majorVer > 3 || (majorVer >= 2 && minorVer >= 53) ? 'external' : true; + const cssOptionValue = majorVer > 3 || (majorVer >= 3 && minorVer >= 53) ? 'external' : true; if (compilerOptions.css) { console.warn( `${PREFIX} Forcing \`"compilerOptions.css": ${typeof cssOptionValue === 'string' ? `"${cssOptionValue}"` : cssOptionValue}\` because "emitCss" was truthy.` From 07e96c3fb5758fb4595d8dc6a174473127503e80 Mon Sep 17 00:00:00 2001 From: gucheen Date: Mon, 26 Jun 2023 16:32:50 +0800 Subject: [PATCH 4/5] feat: use new css option after svelte v4 --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 226cad3..57b3d03 100644 --- a/index.js +++ b/index.js @@ -42,8 +42,8 @@ module.exports = function (options = {}) { const { onwarn, emitCss = true } = rest; if (emitCss) { - const [majorVer, minorVer] = VERSION.split('.'); - const cssOptionValue = majorVer > 3 || (majorVer >= 3 && minorVer >= 53) ? 'external' : true; + const [majorVer] = VERSION.split('.'); + const cssOptionValue = majorVer > 3 ? 'external' : true; if (compilerOptions.css) { console.warn( `${PREFIX} Forcing \`"compilerOptions.css": ${typeof cssOptionValue === 'string' ? `"${cssOptionValue}"` : cssOptionValue}\` because "emitCss" was truthy.` From 1e050e1ccc86802110f6b1457d9e854e174bb3f1 Mon Sep 17 00:00:00 2001 From: gucheen Date: Mon, 26 Jun 2023 16:38:36 +0800 Subject: [PATCH 5/5] fix: css boolean value --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 57b3d03..89b2366 100644 --- a/index.js +++ b/index.js @@ -43,7 +43,7 @@ module.exports = function (options = {}) { if (emitCss) { const [majorVer] = VERSION.split('.'); - const cssOptionValue = majorVer > 3 ? 'external' : true; + const cssOptionValue = majorVer > 3 ? 'external' : false; if (compilerOptions.css) { console.warn( `${PREFIX} Forcing \`"compilerOptions.css": ${typeof cssOptionValue === 'string' ? `"${cssOptionValue}"` : cssOptionValue}\` because "emitCss" was truthy.`