MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / wrapEnvironmentTransform

Function wrapEnvironmentTransform

packages/vite/src/bridge/build.ts:195–217  ·  view source on GitHub ↗
(environment: BuildEnvironment, hook?: Plugin['transform'])

Source from the content-addressed store, hash-verified

193}
194
195function wrapEnvironmentTransform(environment: BuildEnvironment, hook?: Plugin['transform']): Plugin['transform'] {
196 if (!hook) {
197 return;
198 }
199
200 const fn = getHookHandler(hook);
201 const handler: Plugin['transform'] = function (code, importer, ...args) {
202 return fn.call(
203 injectEnvironmentInContext(this, environment),
204 code,
205 importer,
206 injectSsrFlag(args[0], environment)
207 );
208 };
209
210 if ('handler' in hook) {
211 return {
212 ...hook,
213 handler
214 } as Plugin['transform'];
215 }
216 return handler;
217}
218
219function wrapEnvironmentHook<HookName extends keyof Plugin>(
220 environment: BuildEnvironment,

Callers 1

injectEnvironmentToHooksFunction · 0.85

Calls 1

getHookHandlerFunction · 0.90

Tested by

no test coverage detected