feat: add build.target option (#1798)
This commit is contained in:
@@ -20,6 +20,7 @@ export interface EsbuildBuilderOptions {
|
||||
configPath: string;
|
||||
/** The JSX configuration. */
|
||||
jsxConfig: JSXConfig;
|
||||
target: string | string[];
|
||||
}
|
||||
|
||||
export interface JSXConfig {
|
||||
@@ -55,7 +56,7 @@ export class EsbuildBuilder implements Builder {
|
||||
entryPoints: opts.entrypoints,
|
||||
|
||||
platform: "browser",
|
||||
target: ["chrome99", "firefox99", "safari15"],
|
||||
target: this.#options.target,
|
||||
|
||||
format: "esm",
|
||||
bundle: true,
|
||||
|
||||
@@ -61,6 +61,7 @@ export async function getFreshConfigWithDefaults(
|
||||
manifest,
|
||||
build: {
|
||||
outDir: "",
|
||||
target: opts.build?.target ?? ["chrome99", "firefox99", "safari15"],
|
||||
},
|
||||
plugins: opts.plugins ?? [],
|
||||
staticDir: "",
|
||||
|
||||
@@ -382,6 +382,7 @@ export async function getServerContext(opts: InternalFreshOptions) {
|
||||
jsxConfig,
|
||||
opts.dev,
|
||||
opts.router ?? DEFAULT_ROUTER_OPTIONS,
|
||||
opts.build.target,
|
||||
snapshot,
|
||||
);
|
||||
}
|
||||
@@ -416,6 +417,7 @@ export class ServerContext {
|
||||
jsxConfig: JSXConfig,
|
||||
dev: boolean,
|
||||
routerOptions: RouterOptions,
|
||||
target: string | string[],
|
||||
snapshot: BuildSnapshot | null = null,
|
||||
) {
|
||||
this.#routes = routes;
|
||||
@@ -435,6 +437,7 @@ export class ServerContext {
|
||||
configPath,
|
||||
dev: this.#dev,
|
||||
jsxConfig,
|
||||
target,
|
||||
});
|
||||
this.#routerOptions = routerOptions;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,13 @@ export interface FreshOptions {
|
||||
* This can be an absolute path, a file URL or a relative path.
|
||||
*/
|
||||
outDir?: string;
|
||||
/**
|
||||
* This sets the target environment for the generated code. Newer
|
||||
* language constructs will be transformed to match the specified
|
||||
* support range. See https://esbuild.github.io/api/#target
|
||||
* @default {"es2022"}
|
||||
*/
|
||||
target?: string | string[];
|
||||
};
|
||||
render?: RenderFunction;
|
||||
plugins?: Plugin[];
|
||||
@@ -47,6 +54,7 @@ export interface InternalFreshOptions {
|
||||
manifest: Manifest;
|
||||
build: {
|
||||
outDir: string;
|
||||
target: string | string[];
|
||||
};
|
||||
render?: RenderFunction;
|
||||
plugins: Plugin[];
|
||||
|
||||
Reference in New Issue
Block a user