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

Function wrapEnvironmentLoad

packages/vite/src/node/build.ts:1392–1413  ·  view source on GitHub ↗
(
  environment: Environment,
  hook: Plugin['load'] | undefined,
  pluginName: string,
)

Source from the content-addressed store, hash-verified

1390}
1391
1392function wrapEnvironmentLoad(
1393 environment: Environment,
1394 hook: Plugin['load'] | undefined,
1395 pluginName: string,
1396): Plugin['load'] {
1397 if (!hook) return
1398
1399 const fn = getHookHandler(hook)
1400 const handler: Plugin['load'] = function (id, ...args) {
1401 return fn.call(
1402 injectEnvironmentInContext(this, environment),
1403 id,
1404 injectSsrFlag(args[0], environment, pluginName),
1405 )
1406 }
1407
1408 if ('handler' in hook) {
1409 return wrapHookObject(hook, handler)
1410 } else {
1411 return handler
1412 }
1413}
1414
1415function wrapEnvironmentTransform(
1416 environment: Environment,

Callers 1

injectEnvironmentToHooksFunction · 0.85

Calls 2

getHookHandlerFunction · 0.90
wrapHookObjectFunction · 0.85

Tested by

no test coverage detected