File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
packages/vite-plugin-svelte/src Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,9 @@ export interface SvelteConfig {
136136 /**
137137 * Handles warning emitted from the Svelte compiler
138138 *
139+ * warnings emitted for files in node_modules are logged at the debug level, to see them run
140+ * `DEBUG=vite-plugin-svelte:node-modules-onwarn pnpm build`
141+ *
139142 * @example
140143 * ```
141144 * (warning, defaultHandler) => {
@@ -145,6 +148,7 @@ export interface SvelteConfig {
145148 * }
146149 * }
147150 * ```
151+ *
148152 */
149153 onwarn ?: ( warning : Warning , defaultHandler : ( warning : Warning ) => void ) => void ;
150154 /**
Original file line number Diff line number Diff line change @@ -226,14 +226,26 @@ function buildExtraWarnings(warnings, isBuild) {
226226 * @param {import('svelte/compiler').Warning } w
227227 */
228228function warnDev ( w ) {
229- if ( log . info . enabled ) log . info ( buildExtendedLogMessage ( w ) ) ;
229+ if ( w . filename ?. includes ( 'node_modules' ) ) {
230+ if ( isDebugNamespaceEnabled ( 'node-modules-onwarn' ) ) {
231+ log . debug ( buildExtendedLogMessage ( w ) , undefined , 'node-modules-onwarn' ) ;
232+ }
233+ } else if ( log . info . enabled ) {
234+ log . info ( buildExtendedLogMessage ( w ) ) ;
235+ }
230236}
231237
232238/**
233239 * @param {import('svelte/compiler').Warning & {frame?: string} } w
234240 */
235241function warnBuild ( w ) {
236- if ( log . warn . enabled ) log . warn ( buildExtendedLogMessage ( w ) , w . frame ) ;
242+ if ( w . filename ?. includes ( 'node_modules' ) ) {
243+ if ( isDebugNamespaceEnabled ( 'node-modules-onwarn' ) ) {
244+ log . debug ( buildExtendedLogMessage ( w ) , w . frame , 'node-modules-onwarn' ) ;
245+ }
246+ } else if ( log . warn . enabled ) {
247+ log . warn ( buildExtendedLogMessage ( w ) , w . frame ) ;
248+ }
237249}
238250
239251/**
You can’t perform that action at this time.
0 commit comments