-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor esbuild options into a reusable function
- Loading branch information
1 parent
44962c9
commit f96b2d6
Showing
2 changed files
with
22 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { BuildOptions } from "esbuild"; | ||
import { join } from "node:path"; | ||
import { RuntimeConfig } from "./runtimeConfig"; | ||
|
||
export function getEsbuildOptions( | ||
functionConfig: RuntimeConfig, | ||
outputDirectory: string, | ||
additionalOptions?: Partial<BuildOptions>, | ||
): Partial<BuildOptions> { | ||
return { | ||
entryPoints: [functionConfig.file], | ||
absWorkingDir: process.cwd(), // We should probably infer the working directory from the cloudseed.json file | ||
format: "cjs", | ||
bundle: true, | ||
platform: "node", | ||
outfile: join(outputDirectory, `functions/${functionConfig.name}/index.js`), | ||
sourcemap: "both", | ||
...additionalOptions, | ||
}; | ||
} |