(build)
| 219 | const fillPlugin = ({ fillerOverrides, defaultFillers = true }: FillPluginOptions): esbuild.Plugin => ({ |
| 220 | name: 'fillPlugin', |
| 221 | setup(build) { |
| 222 | const uid = Math.random().toString(36).substring(7) + '' |
| 223 | const namespace = `fill-plugin-${uid}` |
| 224 | |
| 225 | // overrides |
| 226 | const fillers = { |
| 227 | ...(defaultFillers ? defaultFillersConfig : {}), |
| 228 | ...fillerOverrides, |
| 229 | } |
| 230 | |
| 231 | // our first step is to update options with basic injections |
| 232 | setInjectionsAndDefinitions(fillers, build.initialOptions) |
| 233 | |
| 234 | // allows us to change the path of a filtered import by another |
| 235 | build.onResolve({ filter: createImportFilter(fillers) }, (args) => { |
| 236 | return onResolve(fillers, args, namespace) |
| 237 | }) |
| 238 | |
| 239 | // if no path was provided it defers to virtual nsp `fill-plugin` |
| 240 | build.onLoad({ filter: /.*/, namespace }, (args) => { |
| 241 | return onLoad(fillers, args) |
| 242 | }) |
| 243 | }, |
| 244 | }) |
| 245 | |
| 246 | export { fillPlugin } |
nothing calls this directly
no test coverage detected