|
1 | | -import gensync from "gensync"; |
2 | | - |
3 | | -import type { Handler } from "gensync"; |
| 1 | +import gensync, { type Handler } from "gensync"; |
| 2 | +import { once } from "../gensync-utils/functional"; |
4 | 3 |
|
5 | 4 | import { loadPlugin, loadPreset } from "./files"; |
6 | 5 |
|
@@ -123,35 +122,22 @@ export function createUncachedDescriptors( |
123 | 122 | options: ValidatedOptions, |
124 | 123 | alias: string, |
125 | 124 | ): OptionsAndDescriptors { |
126 | | - // The returned result here is cached to represent a config object in |
127 | | - // memory, so we build and memoize the descriptors to ensure the same |
128 | | - // values are returned consistently. |
129 | | - let plugins: UnloadedDescriptor[]; |
130 | | - let presets: UnloadedDescriptor[]; |
131 | | - |
132 | 125 | return { |
133 | 126 | options: optionsWithResolvedBrowserslistConfigFile(options, dirname), |
134 | | - *plugins() { |
135 | | - if (!plugins) { |
136 | | - plugins = yield* createPluginDescriptors( |
137 | | - options.plugins || [], |
138 | | - dirname, |
139 | | - alias, |
140 | | - ); |
141 | | - } |
142 | | - return plugins; |
143 | | - }, |
144 | | - *presets() { |
145 | | - if (!presets) { |
146 | | - presets = yield* createPresetDescriptors( |
147 | | - options.presets || [], |
148 | | - dirname, |
149 | | - alias, |
150 | | - !!options.passPerPreset, |
151 | | - ); |
152 | | - } |
153 | | - return presets; |
154 | | - }, |
| 127 | + // The returned result here is cached to represent a config object in |
| 128 | + // memory, so we build and memoize the descriptors to ensure the same |
| 129 | + // values are returned consistently. |
| 130 | + plugins: once(() => |
| 131 | + createPluginDescriptors(options.plugins || [], dirname, alias), |
| 132 | + ), |
| 133 | + presets: once(() => |
| 134 | + createPresetDescriptors( |
| 135 | + options.presets || [], |
| 136 | + dirname, |
| 137 | + alias, |
| 138 | + !!options.passPerPreset, |
| 139 | + ), |
| 140 | + ), |
155 | 141 | }; |
156 | 142 | } |
157 | 143 |
|
|
0 commit comments