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 {
136
136
/**
137
137
* Handles warning emitted from the Svelte compiler
138
138
*
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
+ *
139
142
* @example
140
143
* ```
141
144
* (warning, defaultHandler) => {
@@ -145,6 +148,7 @@ export interface SvelteConfig {
145
148
* }
146
149
* }
147
150
* ```
151
+ *
148
152
*/
149
153
onwarn ?: ( warning : Warning , defaultHandler : ( warning : Warning ) => void ) => void ;
150
154
/**
Original file line number Diff line number Diff line change @@ -226,14 +226,26 @@ function buildExtraWarnings(warnings, isBuild) {
226
226
* @param {import('svelte/compiler').Warning } w
227
227
*/
228
228
function 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
+ }
230
236
}
231
237
232
238
/**
233
239
* @param {import('svelte/compiler').Warning & {frame?: string} } w
234
240
*/
235
241
function 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
+ }
237
249
}
238
250
239
251
/**
You can’t perform that action at this time.
0 commit comments