Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cuddly-bars-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/vite-plugin-svelte': patch
---

reduce deprecation logging to info and allow disabling it with a flag
7 changes: 7 additions & 0 deletions packages/vite-plugin-svelte/src/public.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ interface ExperimentalOptions {
*/
disableSvelteResolveWarnings?: boolean;

/**
* disable api.sveltePreprocess deprecation warnings
*
* @default false
*/
disableApiSveltePreprocessWarnings?: boolean;

compileModule?: CompileModuleOptions;
}

Expand Down
3 changes: 3 additions & 0 deletions packages/vite-plugin-svelte/src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export const SVELTE_EXPORT_CONDITIONS = ['svelte'];
export const FAQ_LINK_MISSING_EXPORTS_CONDITION =
'https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#missing-exports-condition';

export const LINK_TRANSFORM_WITH_PLUGIN =
'https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/advanced-usage.md#transform-svelte-files-with-vite-plugins';

export const DEFAULT_SVELTE_EXT = ['.svelte'];
export const DEFAULT_SVELTE_MODULE_INFIX = ['.svelte.'];
export const DEFAULT_SVELTE_MODULE_EXT = ['.js', '.ts'];
Expand Down
5 changes: 3 additions & 2 deletions packages/vite-plugin-svelte/src/utils/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,12 @@ async function buildExtraConfigForDependencies(options, config) {
}
});
if (
!options.isBuild &&
!options.experimental?.disableSvelteResolveWarnings &&
packagesWithoutSvelteExportsCondition?.size > 0
) {
log.warn(
`WARNING: The following packages have a svelte field in their package.json but no exports condition for svelte.\n\n${[
log.info.once(
`The following packages have a svelte field in their package.json but no exports condition for svelte.\n\n${[
...packagesWithoutSvelteExportsCondition
].join('\n')}\n\nPlease see ${FAQ_LINK_MISSING_EXPORTS_CONDITION} for details.`
);
Expand Down
22 changes: 15 additions & 7 deletions packages/vite-plugin-svelte/src/utils/preprocess.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { log } from './log.js';
import { LINK_TRANSFORM_WITH_PLUGIN } from './constants.js';

/**
* @param {import('../types/options.d.ts').ResolvedOptions} options
Expand All @@ -14,17 +15,24 @@ function buildExtraPreprocessors(options, config) {
/** @type {import('svelte/compiler').PreprocessorGroup[]} */
const appendPreprocessors = [];

const pluginsWithPreprocessorsDeprecated = config.plugins.filter((p) => p.api?.sveltePreprocess);
if (pluginsWithPreprocessorsDeprecated.length > 0) {
log.warn(
`The following plugins use the deprecated 'plugin.api.sveltePreprocess' field. Please contact their maintainers and ask them to use a vite plugin transform instead: ${pluginsWithPreprocessorsDeprecated
/** @type {import('vite').Plugin[]} */
const pluginsWithPreprocessors = config.plugins.filter((p) => p?.api?.sveltePreprocess);

if (
!options.isBuild &&
!options.experimental?.disableApiSveltePreprocessWarnings &&
pluginsWithPreprocessors.length > 0
) {
log.info.once(
`The following plugins use the deprecated 'plugin.api.sveltePreprocess' field: ${pluginsWithPreprocessors
.map((p) => p.name)
.join(', ')}`
.join(', ')}
Please contact their maintainers and ask them to use a vite plugin transform instead.
See ${LINK_TRANSFORM_WITH_PLUGIN} for more information.
`.replace(/\t+/g, '\t')
);
}
/** @type {import('vite').Plugin[]} */
const pluginsWithPreprocessors = config.plugins.filter((p) => p?.api?.sveltePreprocess);
/** @type {import('vite').Plugin[]} */
const ignored = [];
/** @type {import('vite').Plugin[]} */
const included = [];
Expand Down
7 changes: 7 additions & 0 deletions packages/vite-plugin-svelte/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ declare module '@sveltejs/vite-plugin-svelte' {
*/
disableSvelteResolveWarnings?: boolean;

/**
* disable api.sveltePreprocess deprecation warnings
*
* @default false
*/
disableApiSveltePreprocessWarnings?: boolean;

compileModule?: CompileModuleOptions;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin-svelte/types/index.d.ts.map
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
null,
null
],
"mappings": ";;;;aAIYA,OAAOA;;WAETC,mBAAmBA;;;;;;;;;;;kBAWZC,aAAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAgGbC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAiDnBC,mBAAmBA;;;;;;;;;;;;;;;;WAgBnBC,oBAAoBA;;;;;;;;;;;;;;;MAezBC,SAASA;;kBAEGC,qBAAqBA;;;;;;;;;;;;;;;;;;iBChLtBC,MAAMA;iBCMNC,cAAcA;iBCFRC,gBAAgBA",
"mappings": ";;;;aAIYA,OAAOA;;WAETC,mBAAmBA;;;;;;;;;;;kBAWZC,aAAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAgGbC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAiDnBC,mBAAmBA;;;;;;;;;;;;;;;;;;;;;;;WAuBnBC,oBAAoBA;;;;;;;;;;;;;;;MAezBC,SAASA;;kBAEGC,qBAAqBA;;;;;;;;;;;;;;;;;;iBCvLtBC,MAAMA;iBCMNC,cAAcA;iBCFRC,gBAAgBA",
"ignoreList": []
}