(optimizerOptions: OptimizerOptions = {})
| 14 | |
| 15 | /** @public */ |
| 16 | export const createOptimizer = async (optimizerOptions: OptimizerOptions = {}) => { |
| 17 | const sys = optimizerOptions?.sys || (await getSystem()); |
| 18 | const binding = optimizerOptions?.binding || (await loadPlatformBinding(sys)); |
| 19 | |
| 20 | const optimizer: Optimizer = { |
| 21 | async transformModules(opts: TransformModulesOptions) { |
| 22 | return transformModulesSync(binding, opts); |
| 23 | }, |
| 24 | transformModulesSync(opts: TransformModulesOptions) { |
| 25 | return transformModulesSync(binding, opts); |
| 26 | }, |
| 27 | async transformFs(opts: TransformFsOptions) { |
| 28 | return transformFsAsync(sys, binding, opts); |
| 29 | }, |
| 30 | transformFsSync(opts: TransformFsOptions) { |
| 31 | return transformFsSync(binding, opts); |
| 32 | }, |
| 33 | sys, |
| 34 | }; |
| 35 | |
| 36 | return optimizer; |
| 37 | }; |
| 38 | |
| 39 | /** Transforms the input code string, does not access the file system. */ |
| 40 | const transformModulesSync = (binding: PlatformBinding, opts: TransformModulesOptions) => { |
no test coverage detected
searching dependent graphs…