* Handles the resolution step where esbuild resolves the imports before * bundling them. This allows us to inject a filler via its `path` if it was * provided. If not, we proceed to the next `onLoad` step. * @param fillers to use the path from * @param args from esbuild * @returns
(fillers: Fillers, args: esbuild.OnResolveArgs, namespace: string)
| 98 | * @returns |
| 99 | */ |
| 100 | function onResolve(fillers: Fillers, args: esbuild.OnResolveArgs, namespace: string): esbuild.OnResolveResult { |
| 101 | // removes trailing slashes in imports paths |
| 102 | const path = args.path.replace(/\/$/, '') |
| 103 | const item = fillers[path] |
| 104 | |
| 105 | // if a path is provided, we just replace it |
| 106 | if (item.imports !== undefined) { |
| 107 | return { path: item.imports } |
| 108 | } |
| 109 | |
| 110 | // if not, we defer action to the loaders cb |
| 111 | return { |
| 112 | namespace, |
| 113 | path: path, |
| 114 | pluginData: args.importer, |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Handles the load step where esbuild loads the contents of the imports before |