MCPcopy
hub / github.com/vitejs/vite / warnFutureDeprecation

Function warnFutureDeprecation

packages/vite/src/node/deprecations.ts:55–97  ·  view source on GitHub ↗
(
  config: ResolvedConfig,
  type: keyof FutureOptions,
  extraMessage?: string,
  stacktrace = true,
)

Source from the content-addressed store, hash-verified

53 * Warn about future deprecations.
54 */
55export function warnFutureDeprecation(
56 config: ResolvedConfig,
57 type: keyof FutureOptions,
58 extraMessage?: string,
59 stacktrace = true,
60): void {
61 if (
62 _ignoreDeprecationWarnings ||
63 !config.future ||
64 config.future[type] !== 'warn'
65 )
66 return
67
68 let msg = `[vite future] ${deprecationMessages[type]}`
69 if (extraMessage) {
70 msg += ` ${extraMessage}`
71 }
72 msg = colors.yellow(msg)
73
74 const docs = `${docsURL}/changes/${deprecationCode[type].toLowerCase()}`
75 msg +=
76 colors.gray(`\n ${stacktrace ? '├' : '└'}─── `) +
77 colors.underline(docs) +
78 '\n'
79
80 if (stacktrace) {
81 const stack = new Error().stack
82 if (stack) {
83 let stacks = stack
84 .split('\n')
85 .slice(3)
86 .filter((i) => !i.includes('/node_modules/vite/dist/'))
87 if (stacks.length === 0) {
88 stacks.push('No stack trace found.')
89 }
90 stacks = stacks.map(
91 (i, idx) => ` ${idx === stacks.length - 1 ? '└' : '│'} ${i.trim()}`,
92 )
93 msg += colors.dim(stacks.join('\n')) + '\n'
94 }
95 }
96 config.logger.warnOnce(msg)
97}
98
99export function ignoreDeprecationWarnings<T>(fn: () => T): T {
100 const before = _ignoreDeprecationWarnings

Callers 12

getFunction · 0.90
getMethod · 0.90
hotFunction · 0.90
pluginContainerFunction · 0.90
moduleGraphFunction · 0.90
transformRequestFunction · 0.90
warmupRequestFunction · 0.90
ssrLoadModuleFunction · 0.90
ssrFixStacktraceFunction · 0.90
ssrRewriteStacktraceFunction · 0.90
reloadModuleFunction · 0.90
handleHMRUpdateFunction · 0.90

Calls 1

warnOnceMethod · 0.65

Tested by

no test coverage detected