@sveltejs/vite-plugin-svelte
Advanced tools
Comparing version 4.0.2 to 4.0.3
{ | ||
"name": "@sveltejs/vite-plugin-svelte", | ||
"version": "4.0.2", | ||
"version": "4.0.3", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": "dominikg", |
@@ -105,2 +105,12 @@ import { buildExtendedLogMessage } from './log.js'; | ||
/** | ||
* | ||
* @param {string} code the svelte error code | ||
* @see https://github.com/sveltejs/svelte/blob/main/packages/svelte/src/compiler/errors.js | ||
* @returns {boolean} | ||
*/ | ||
function couldBeFixedByCssPreprocessor(code) { | ||
return code === 'expected_token' || code === 'unexpected_eof' || code.startsWith('css_'); | ||
} | ||
/** | ||
* @param {import('svelte/compiler').Warning & Error} err a svelte compiler error, which is a mix of Warning and an error | ||
@@ -117,3 +127,3 @@ * @param {string} originalCode | ||
// Handle incorrect CSS preprocessor usage | ||
if (err.code === 'css-syntax-error') { | ||
if (couldBeFixedByCssPreprocessor(err.code)) { | ||
// Reference from Svelte: https://github.com/sveltejs/svelte/blob/9926347ad9dbdd0f3324d5538e25dcb7f5e442f8/packages/svelte/src/compiler/preprocess/index.js#L257 | ||
@@ -120,0 +130,0 @@ const styleRe = |
@@ -185,3 +185,3 @@ /* eslint-disable no-console */ | ||
return ( | ||
(!emitCss && warning.code === 'css-unused-selector') || // same as rollup-plugin-svelte | ||
(!emitCss && warning.code === 'css_unused_selector') || // same as rollup-plugin-svelte | ||
(!isBuild && isNoScopableElementWarning(warning)) | ||
@@ -198,3 +198,3 @@ ); | ||
// see https://github.com/sveltejs/vite-plugin-svelte/issues/153 | ||
return warning.code === 'css-unused-selector' && warning.message.includes('"*"'); | ||
return warning.code === 'css_unused_selector' && warning.message.includes('"*"'); | ||
} | ||
@@ -201,0 +201,0 @@ |
124963
3744