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

Function injectSsrFlag

packages/vite/src/node/build.ts:1510–1542  ·  view source on GitHub ↗
(
  options: T | undefined,
  environment: Environment,
  pluginName: string,
)

Source from the content-addressed store, hash-verified

1508}
1509
1510function injectSsrFlag<T extends Record<string, any>>(
1511 options: T | undefined,
1512 environment: Environment,
1513 pluginName: string,
1514): T & { ssr?: boolean } {
1515 let ssr = environment.config.consumer === 'server'
1516 const newOptions = { ...(options ?? {}), ssr } as T & {
1517 ssr?: boolean
1518 }
1519
1520 if (
1521 isFutureDeprecationEnabled(
1522 environment?.getTopLevelConfig(),
1523 'removePluginHookSsrArgument',
1524 )
1525 ) {
1526 Object.defineProperty(newOptions, 'ssr', {
1527 get() {
1528 warnFutureDeprecation(
1529 environment?.getTopLevelConfig(),
1530 'removePluginHookSsrArgument',
1531 `Used in plugin "${pluginName}".`,
1532 )
1533 return ssr
1534 },
1535 set(v) {
1536 ssr = v
1537 },
1538 })
1539 }
1540
1541 return newOptions
1542}
1543
1544/*
1545 The following functions are copied from rollup

Callers 1

handlerFunction · 0.85

Calls 2

getTopLevelConfigMethod · 0.80

Tested by

no test coverage detected