(environment: BuildEnvironment, hook?: Plugin['transform'])
| 193 | } |
| 194 | |
| 195 | function 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 | |
| 219 | function wrapEnvironmentHook<HookName extends keyof Plugin>( |
| 220 | environment: BuildEnvironment, |
no test coverage detected