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

Function injectEnvironmentToHooks

packages/vite/src/bridge/build.ts:122–150  ·  view source on GitHub ↗
(environment: BuildEnvironment, plugin: Plugin)

Source from the content-addressed store, hash-verified

120 * @internal
121 */
122export function injectEnvironmentToHooks(environment: BuildEnvironment, plugin: Plugin): Plugin {
123 const { resolveId, load, transform } = plugin;
124
125 const clone = { ...plugin };
126
127 for (const hook of Object.keys(clone) as RollupPluginHooks[]) {
128 switch (hook) {
129 case 'resolveId':
130 clone[hook] = wrapEnvironmentResolveId(environment, resolveId);
131 break;
132 case 'load':
133 clone[hook] = wrapEnvironmentLoad(environment, load);
134 break;
135 case 'transform':
136 clone[hook] = wrapEnvironmentTransform(environment, transform);
137 break;
138 default:
139 // ROLLUP_HOOKS enumerates the full rollup hook set; the
140 // `.includes` guard skips hooks the active plugin (and the
141 // active bundler — rolldown drops some) does not declare.
142 if (ROLLUP_HOOKS.includes(hook)) {
143 (clone as any)[hook] = wrapEnvironmentHook(environment, (clone as any)[hook]);
144 }
145 break;
146 }
147 }
148
149 return clone;
150}
151
152function wrapEnvironmentResolveId(environment: BuildEnvironment, hook?: Plugin['resolveId']): Plugin['resolveId'] {
153 if (!hook) {

Callers 1

bundleWorkerEntryFunction · 0.90

Calls 6

wrapEnvironmentResolveIdFunction · 0.85
wrapEnvironmentLoadFunction · 0.85
wrapEnvironmentTransformFunction · 0.85
wrapEnvironmentHookFunction · 0.85
includesMethod · 0.80
keysMethod · 0.45

Tested by

no test coverage detected