forked from redwoodjs/redwood
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:redwoodjs/redwood into feat/ssr-mid…
…dleware * 'main' of github.com:redwoodjs/redwood: chore(structure): switch to vitest (redwoodjs#9878) chore(cli): switch to vitest (redwoodjs#9863) feat(dbAuth): Refactor dbAuthHandler to support WebAPI Request events (redwoodjs#9835) fix(crwa): remove yarn-install option for yarn 1 (redwoodjs#9881) chore(esbuild): dedupe esbuild config (redwoodjs#9875) chore(esm): convert `@redwoodjs/cli-helpers` to ESM (redwoodjs#9872) fix(studio): Add version checks when first running Studio (redwoodjs#9876)
- Loading branch information
Showing
200 changed files
with
5,922 additions
and
2,771 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import path from 'node:path' | ||
|
||
import * as esbuild from 'esbuild' | ||
import fg from 'fast-glob' | ||
import fs from 'fs-extra' | ||
|
||
export const defaultBuildOptions = { | ||
outdir: 'dist', | ||
|
||
platform: 'node', | ||
target: ['node20'], | ||
|
||
format: 'cjs', | ||
|
||
logLevel: 'info', | ||
|
||
// For visualizing dist. See: | ||
// - https://esbuild.github.io/api/#metafile | ||
// - https://esbuild.github.io/analyze/ | ||
metafile: true, | ||
} | ||
|
||
export const defaultPatterns = ['./src/**/*.{ts,js}'] | ||
export const defaultIgnorePatterns = ['**/__tests__', '**/*.test.{ts,js}'] | ||
|
||
/** | ||
* @typedef {{ | ||
* cwd?: string | ||
* buildOptions?: import('esbuild').BuildOptions | ||
* entryPointOptions?: { | ||
* patterns?: string[] | ||
* ignore?: string[] | ||
* } | ||
* metafileName?: string | ||
* }} BuildOptions | ||
* | ||
* @param {BuildOptions} options | ||
*/ | ||
export async function build({ | ||
cwd, | ||
buildOptions, | ||
entryPointOptions, | ||
metafileName, | ||
} = {}) { | ||
// Yarn and Nx both set this to the package's root dir path | ||
cwd ??= process.cwd() | ||
|
||
buildOptions ??= defaultBuildOptions | ||
metafileName ??= 'meta.json' | ||
|
||
// If the user didn't explicitly provide entryPoints, | ||
// then we'll use fg to find all the files in `${cwd}/src` | ||
let entryPoints = buildOptions.entryPoints | ||
|
||
if (!entryPoints) { | ||
const patterns = entryPointOptions?.patterns ?? defaultPatterns | ||
const ignore = entryPointOptions?.ignore ?? defaultIgnorePatterns | ||
|
||
entryPoints = await fg(patterns, { | ||
cwd, | ||
ignore, | ||
}) | ||
} | ||
|
||
const result = await esbuild.build({ | ||
entryPoints, | ||
...buildOptions, | ||
}) | ||
|
||
await fs.writeJSON(path.join(cwd, metafileName), result.metafile, { | ||
spaces: 2, | ||
}) | ||
} |
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
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
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,15 @@ | ||
import type { APIGatewayProxyEvent } from 'aws-lambda' | ||
|
||
import { isFetchApiRequest } from './transforms' | ||
|
||
// Extracts the header from an event, handling lower and upper case header names. | ||
export const getEventHeader = ( | ||
event: APIGatewayProxyEvent | Request, | ||
headerName: string | ||
) => { | ||
if (isFetchApiRequest(event)) { | ||
return event.headers.get(headerName) | ||
} | ||
|
||
return event.headers[headerName] || event.headers[headerName.toLowerCase()] | ||
} |
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
Oops, something went wrong.