Skip to content
Open
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
4 changes: 3 additions & 1 deletion packages/cli-v3/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ export function configPlugin(resolvedConfig: ResolvedConfig): esbuild.Plugin | u
? $mod.exports.config.$args[0]
: $mod.exports.config;

options.build = {};
if (options && typeof options === "object") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Data Integrity & Integration · Quick win

Supported by static analysis

Script executed:

# 1. Plugin source around the changed guard, with original line numbers.
cat -n packages/cli-v3/src/config.ts | sed -n '100,160p'

# 2. Declared and locked versions of the libraries behind the claim.
rg -n '"(c12|magicast|jiti)"' packages/cli-v3/package.json || test "$?" -eq 1
rg -n -A2 '^  (magicast|c12|jiti)@' pnpm-lock.yaml || test "$?" -eq 1

# 3. Installed sources, if the sandbox has them (node_modules is often absent).
for d in node_modules/magicast node_modules/.pnpm/magicast@0.3.4*/node_modules/magicast node_modules/.pnpm/c12@*/node_modules/c12; do
  test -d "$d" && echo "FOUND $d" && ls "$d"
done
test -d node_modules/.pnpm && rg -l -F 'defaultExport' node_modules/.pnpm/magicast@* 2>/dev/null | head -n 20 || true

Repository: triggerdotdev/trigger.dev

Length of output: 4778


Script executed:

# Locate export handling in the installed magicast 0.3.4 dist.
rg -n -e 'ExportSpecifier' -e 'ExportDefaultDeclaration' -e 'ExportNamedDeclaration' node_modules/.pnpm/magicast@0.3.4/node_modules/magicast/dist || test "$?" -eq 1

# Show the surrounding exports-proxy construction for any hit.
for f in $(rg -l -e 'ExportSpecifier' -e 'ExportDefaultDeclaration' node_modules/.pnpm/magicast@0.3.4/node_modules/magicast/dist || true); do
  echo "== $f"
  rg -n -C6 -e 'ExportSpecifier' -e 'ExportDefaultDeclaration' "$f" | head -n 120
done

Repository: triggerdotdev/trigger.dev

Length of output: 16701


Script executed:

# Read the exports-proxy lookup in the installed magicast 0.3.4 ESM dist, with original line numbers.
cat -n node_modules/.pnpm/magicast@0.3.4/node_modules/magicast/dist/index.mjs | sed -n '8595,8685p'

Repository: triggerdotdev/trigger.dev

Length of output: 3623


Specifier-exported configs keep build extensions after this change.

Before this change, a config exported as export { cfg as default } made the trigger-config-strip plugin throw at options.build = {}. The deploy failed. With the new guard at packages/cli-v3/src/config.ts:135, that case no longer fails. Magicast 0.3.4 does not resolve specifier exports for default, so options is undefined and the guard skips stripping. The build section and its extension imports stay in the bundle.

The guard turns a visible failure into a silent one. The worker then loads the build-only extension code that the strip step was meant to remove. Resolve the default export through its specifier, or fail the build when no default export object is found.


Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

sed -n '95,170p' packages/cli-v3/src/config.ts
git diff 7e40289a7cfde2a391b487c0b22fedb3e5e46197 HEAD -- packages/cli-v3/src/config.ts

Repository: triggerdotdev/trigger.dev

Length of output: 3140


Script executed:

rg -n -F -e 'configFile' -- packages/cli-v3/src/config.ts || test "$?" -eq 1
rg -n -F -e 'configPlugin(' -- packages/cli-v3/src || test "$?" -eq 1
sed -n '40,75p' packages/cli-v3/src/config.ts | cat -n

Repository: triggerdotdev/trigger.dev

Length of output: 1860


Only rewrite the selected config file.

The filter matches any bundled file whose path ends in trigger.config.ts. A non-config file with that name and a resolveEnvVars export now builds without error. Its resolveEnvVars export is then set to undefined. Before this change, the same file failed the build. A task that imports that file and calls resolveEnvVars can now fail at runtime.

Limit the rewrite to the file at configFile. Other files that match the filter must load unchanged. Compare the loaded path with the resolved configFile path, not its basename.

options.build = {};
}

// Remove export resolveEnvVars function as well
$mod.exports.resolveEnvVars = undefined;
Expand Down