Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/gold-insects-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"trigger.dev": patch
"@trigger.dev/core": patch
---

Expose esbuild `keepNames` option (experimental)
6 changes: 6 additions & 0 deletions .changeset/wild-mirrors-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"trigger.dev": patch
"@trigger.dev/core": patch
---

Expose esbuild `minify` option (experimental)
7 changes: 5 additions & 2 deletions packages/cli-v3/src/build/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,11 @@ async function createBuildOptions(
options: BundleOptions & { entryPoints: string[]; buildResultPlugin?: esbuild.Plugin }
): Promise<esbuild.BuildOptions & { metafile: true }> {
const customConditions = options.resolvedConfig.build?.conditions ?? [];

const conditions = [...customConditions, "trigger.dev", "module", "node"];

const keepNames = options.resolvedConfig.build?.experimental_keepNames ?? false;
const minify = options.resolvedConfig.build?.experimental_minify ?? false;

const $buildPlugins = await buildPlugins(options.target, options.resolvedConfig);

return {
Expand All @@ -186,13 +188,14 @@ async function createBuildOptions(
bundle: true,
metafile: true,
write: false,
minify: false,
minify,
splitting: true,
charset: "utf8",
platform: "node",
sourcemap: true,
sourcesContent: options.target === "dev",
conditions,
keepNames,
format: "esm",
target: ["node20", "es2022"],
loader: {
Expand Down
28 changes: 28 additions & 0 deletions packages/core/src/v3/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,34 @@ export type TriggerConfig = {
*/
experimental_autoDetectExternal?: boolean;

/**
* **WARNING: This is an experimental feature and might be removed in a future version.**
*
* Preserve the original names of functions and classes in the bundle. This can fix issues with frameworks that rely on the original names for registration and binding, for example MikroORM.
*
* @link https://esbuild.github.io/api/#keep-names
*
* @default false
*
* @deprecated (experimental)
*/
experimental_keepNames?: boolean;

/**
* **WARNING: This is an experimental feature and might be removed in a future version.**
*
* "Minification is not safe for 100% of all JavaScript code" - esbuild docs
*
* Minify the generated code to help decrease bundle size. This may break stuff.
*
* @link https://esbuild.github.io/api/#minify
*
* @default false
*
* @deprecated (experimental)
*/
experimental_minify?: boolean;

jsx?: {
/**
* @default "React.createElement"
Expand Down
15 changes: 8 additions & 7 deletions references/v3-catalog/src/trigger/binaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ function unzip(inputPath: string, outputPath: string) {

import { createClient } from "@1password/sdk";

// Creates an authenticated client.
const client = await createClient({
auth: process.env.OP_SERVICE_ACCOUNT_TOKEN ?? "",
// Set the following to your own integration name and version.
integrationName: "My 1Password Integration",
integrationVersion: "v1.0.0",
});
function create1PasswordClient() {
return createClient({
auth: process.env.OP_SERVICE_ACCOUNT_TOKEN ?? "",
// Set the following to your own integration name and version.
integrationName: "My 1Password Integration",
integrationVersion: "v1.0.0",
});
}

// Fetches a secret.
// const secret = await client.secrets.resolve("op://vault/item/field");
Expand Down
2 changes: 2 additions & 0 deletions references/v3-catalog/trigger.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export default defineConfig({
build: {
conditions: ["react-server"],
experimental_autoDetectExternal: true,
experimental_keepNames: true,
experimental_minify: true,
extensions: [
additionalFiles({
files: ["./wrangler/wrangler.toml"],
Expand Down