Skip to content

Commit 60eea7e

Browse files
committed
fix: remove unscopable global warning
1 parent 6969e81 commit 60eea7e

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

.changeset/quiet-wings-learn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/vite-plugin-svelte': patch
3+
---
4+
5+
fix: remove unscopable global warning

packages/vite-plugin-svelte/src/utils/log.js

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,7 @@ export function logCompilerWarnings(svelteRequest, warnings, options) {
146146
let warn = isBuild ? warnBuild : warnDev;
147147
/** @type {import('svelte/compiler').Warning[]} */
148148
const handledByDefaultWarn = [];
149-
const notIgnored = warnings?.filter((w) => !ignoreCompilerWarning(w, isBuild, emitCss));
150-
const extra = buildExtraWarnings(warnings, isBuild);
151-
const allWarnings = [...notIgnored, ...extra];
149+
const allWarnings = warnings?.filter((w) => !ignoreCompilerWarning(w, isBuild, emitCss));
152150
if (sendViaWS) {
153151
const _warn = warn;
154152
/** @type {(w: import('svelte/compiler').Warning) => void} */
@@ -203,31 +201,6 @@ function isNoScopableElementWarning(warning) {
203201
return warning.code === 'css_unused_selector' && warning.message.includes('"*"');
204202
}
205203

206-
/**
207-
*
208-
* @param {import('svelte/compiler').Warning[]} warnings
209-
* @param {boolean} isBuild
210-
* @returns {import('svelte/compiler').Warning[]}
211-
*/
212-
function buildExtraWarnings(warnings, isBuild) {
213-
const extraWarnings = [];
214-
if (!isBuild) {
215-
const noScopableElementWarnings = warnings.filter((w) => isNoScopableElementWarning(w));
216-
if (noScopableElementWarnings.length > 0) {
217-
// in case there are multiple, use last one as that is the one caused by our *{} rule
218-
const noScopableElementWarning =
219-
noScopableElementWarnings[noScopableElementWarnings.length - 1];
220-
extraWarnings.push({
221-
...noScopableElementWarning,
222-
code: 'vite-plugin-svelte-css-no-scopable-elements',
223-
message:
224-
"No scopable elements found in template. If you're using global styles in the style tag, you should move it into an external stylesheet file and import it in JS. See https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#where-should-i-put-my-global-styles."
225-
});
226-
}
227-
}
228-
return extraWarnings;
229-
}
230-
231204
/**
232205
* @param {import('svelte/compiler').Warning} w
233206
*/

0 commit comments

Comments
 (0)