Skip to content

Commit

Permalink
Allow passing esbuild options
Browse files Browse the repository at this point in the history
  • Loading branch information
codetheweb committed Jan 13, 2024
1 parent a29a976 commit f9b30a8
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface GenerateRouteTypesOpts {
* Set this to true to include them.
*/
includeOpenApiExcludedRoutes?: boolean
esbuildOptions?: esbuild.BuildOptions
}

export const extractRouteSpecs = async (opts: GenerateRouteTypesOpts) => {
Expand Down Expand Up @@ -137,6 +138,7 @@ export const extractRouteSpecs = async (opts: GenerateRouteTypesOpts) => {
const pkg = JSON.parse(pkgRaw)

await esbuild.build({
...opts.esbuildOptions,
stdin: {
contents: entryPointContent,
resolveDir: path.resolve(packageDir),
Expand All @@ -149,6 +151,7 @@ export const extractRouteSpecs = async (opts: GenerateRouteTypesOpts) => {
external: [
...Object.keys(pkg.dependencies),
...Object.keys(pkg.devDependencies),
...(opts.esbuildOptions?.external ?? []),
],
plugins: [
// With this plugin, esbuild will never touch the actual filesystem and thus cannot interact with imports that don't match allowedImportPatterns[].
Expand All @@ -172,6 +175,7 @@ export const extractRouteSpecs = async (opts: GenerateRouteTypesOpts) => {
})
},
},
...(opts.esbuildOptions?.plugins ?? []),
],
})
}

0 comments on commit f9b30a8

Please sign in to comment.