trigger.dev 3.0.0-beta.1 → 3.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -800,7 +800,7 @@ import invariant from "tiny-invariant";
800
800
  import { z as z4 } from "zod";
801
801
 
802
802
  // package.json
803
- var version = "3.0.0-beta.1";
803
+ var version = "3.0.0-beta.3";
804
804
  var dependencies = {
805
805
  "@clack/prompts": "^0.7.0",
806
806
  "@depot/cli": "0.0.1-cli.2.55.0",
@@ -816,7 +816,7 @@ var dependencies = {
816
816
  "@opentelemetry/sdk-trace-base": "^1.22.0",
817
817
  "@opentelemetry/sdk-trace-node": "^1.22.0",
818
818
  "@opentelemetry/semantic-conventions": "^1.22.0",
819
- "@trigger.dev/core": "workspace:^3.0.0-beta.0",
819
+ "@trigger.dev/core": "workspace:^3.0.0-beta.2",
820
820
  "@types/degit": "^2.8.3",
821
821
  chalk: "^5.2.0",
822
822
  chokidar: "^3.5.3",
@@ -1643,9 +1643,6 @@ import checkForUpdate from "update-check";
1643
1643
  import chalk2 from "chalk";
1644
1644
  var green = "#4FFF54";
1645
1645
  var purple = "#735BF3";
1646
- function chalkPurple(text2) {
1647
- return chalk2.hex(purple)(text2);
1648
- }
1649
1646
  function chalkGrey(text2) {
1650
1647
  return chalk2.hex("#878C99")(text2);
1651
1648
  }
@@ -1736,7 +1733,7 @@ ${logo()} ${chalkGrey("(v3 Developer Preview)")}`;
1736
1733
  }
1737
1734
  function printDevBanner() {
1738
1735
  logger.log(
1739
- `${chalkGrey("Key:")} ${chalkWorker("Worker")} ${chalkGrey("|")} ${chalkTask(
1736
+ `${chalkGrey("Key:")} ${chalkWorker("Version")} ${chalkGrey("|")} ${chalkTask(
1740
1737
  "Task"
1741
1738
  )} ${chalkGrey("|")} ${chalkRun("Run")}`
1742
1739
  );
@@ -2722,9 +2719,9 @@ ${authorizationCodeResult.error}`
2722
2719
  }
2723
2720
 
2724
2721
  // src/utilities/build.ts
2722
+ import { readFileSync } from "node:fs";
2725
2723
  import { extname, isAbsolute } from "node:path";
2726
2724
  import tsConfigPaths from "tsconfig-paths";
2727
- import { readFileSync } from "node:fs";
2728
2725
  function workerSetupImportConfigPlugin(configPath) {
2729
2726
  return {
2730
2727
  name: "trigger-worker-setup",
@@ -2751,8 +2748,8 @@ function workerSetupImportConfigPlugin(configPath) {
2751
2748
  }
2752
2749
  };
2753
2750
  }
2754
- function bundleDependenciesPlugin(config) {
2755
- const matchPath = config.tsconfigPath ? createMatchPath(config.tsconfigPath) : void 0;
2751
+ function bundleDependenciesPlugin(buildIdentifier, dependenciesToBundle, tsconfigPath) {
2752
+ const matchPath = tsconfigPath ? createMatchPath(tsconfigPath) : void 0;
2756
2753
  function resolvePath(id) {
2757
2754
  if (!matchPath) {
2758
2755
  return id;
@@ -2764,26 +2761,7 @@ function bundleDependenciesPlugin(config) {
2764
2761
  setup(build3) {
2765
2762
  build3.onResolve({ filter: /.*/ }, (args) => {
2766
2763
  const resolvedPath = resolvePath(args.path);
2767
- logger.ignore(`Checking if ${args.path} should be bundled or external`, {
2768
- ...args,
2769
- resolvedPath
2770
- });
2771
2764
  if (!isBareModuleId(resolvedPath)) {
2772
- logger.ignore(`Bundling ${args.path} because its not a bareModuleId`, {
2773
- ...args
2774
- });
2775
- return void 0;
2776
- }
2777
- if (args.path.startsWith("@trigger.dev/")) {
2778
- logger.ignore(`Bundling ${args.path} because its a trigger.dev package`, {
2779
- ...args
2780
- });
2781
- return void 0;
2782
- }
2783
- if (args.path === "superjson" || args.path === "copy-anything" || args.path === "is-what") {
2784
- logger.debug(`Bundling ${args.path} because its superjson/copy-anything/is-what`, {
2785
- ...args
2786
- });
2787
2765
  return void 0;
2788
2766
  }
2789
2767
  let loader;
@@ -2797,12 +2775,12 @@ function bundleDependenciesPlugin(config) {
2797
2775
  if (loader === "file") {
2798
2776
  return void 0;
2799
2777
  }
2800
- for (let pattern of config.dependenciesToBundle ?? []) {
2778
+ for (let pattern of dependenciesToBundle ?? []) {
2801
2779
  if (typeof pattern === "string" ? args.path === pattern : pattern.test(args.path)) {
2802
2780
  return void 0;
2803
2781
  }
2804
2782
  }
2805
- logger.ignore(`Externalizing ${args.path}`, {
2783
+ logger.ignore(`[${buildIdentifier}] Externalizing ${args.path}`, {
2806
2784
  ...args
2807
2785
  });
2808
2786
  return {
@@ -3499,7 +3477,14 @@ async function compileProject(config, options, configPath) {
3499
3477
  TRIGGER_API_URL: `"${config.triggerUrl}"`,
3500
3478
  __PROJECT_CONFIG__: JSON.stringify(config)
3501
3479
  },
3502
- plugins: [bundleDependenciesPlugin(config), workerSetupImportConfigPlugin(configPath)]
3480
+ plugins: [
3481
+ bundleDependenciesPlugin(
3482
+ "workerFacade",
3483
+ config.dependenciesToBundle,
3484
+ config.tsconfigPath
3485
+ ),
3486
+ workerSetupImportConfigPlugin(configPath)
3487
+ ]
3503
3488
  });
3504
3489
  if (result.errors.length > 0) {
3505
3490
  compileSpinner.stop("Build failed, aborting deployment");
@@ -3531,17 +3516,23 @@ async function compileProject(config, options, configPath) {
3531
3516
  write: false,
3532
3517
  minify: false,
3533
3518
  sourcemap: false,
3534
- packages: "external",
3535
- // https://esbuild.github.io/api/#packages
3536
3519
  logLevel: "error",
3537
3520
  platform: "node",
3521
+ packages: "external",
3538
3522
  format: "cjs",
3539
3523
  // This is needed to support opentelemetry instrumentation that uses module patching
3540
3524
  target: ["node18", "es2020"],
3541
3525
  outdir: "out",
3542
3526
  define: {
3543
3527
  __PROJECT_CONFIG__: JSON.stringify(config)
3544
- }
3528
+ },
3529
+ plugins: [
3530
+ bundleDependenciesPlugin(
3531
+ "entryPoint.ts",
3532
+ config.dependenciesToBundle,
3533
+ config.tsconfigPath
3534
+ )
3535
+ ]
3545
3536
  });
3546
3537
  if (entryPointResult.errors.length > 0) {
3547
3538
  compileSpinner.stop("Build failed, aborting deployment");
@@ -3583,6 +3574,10 @@ async function compileProject(config, options, configPath) {
3583
3574
  );
3584
3575
  await writeFile2(join4(tempDir, "worker.js.map"), workerSourcemapFile.text);
3585
3576
  await writeFile2(join4(tempDir, "index.js"), entryPointOutputFile.text);
3577
+ logger.debug("Getting the imports for the worker and entryPoint builds", {
3578
+ workerImports: metaOutput.imports,
3579
+ entryPointImports: entryPointMetaOutput.imports
3580
+ });
3586
3581
  const allImports = [...metaOutput.imports, ...entryPointMetaOutput.imports];
3587
3582
  const externalPackageJson = await readJSONFile(join4(config.projectDir, "package.json"));
3588
3583
  const dependencies2 = await gatherRequiredDependencies(
@@ -3740,7 +3735,7 @@ async function typecheckProject(config, options) {
3740
3735
  async function gatherRequiredDependencies(imports, config, projectPackageJson) {
3741
3736
  const dependencies2 = {};
3742
3737
  for (const file of imports) {
3743
- if (file.kind !== "require-call" || !file.external) {
3738
+ if (file.kind !== "require-call" && file.kind !== "dynamic-import" || !file.external) {
3744
3739
  continue;
3745
3740
  }
3746
3741
  const packageName = detectPackageNameFromImportPath(file.path);
@@ -3842,7 +3837,7 @@ async function findAllEnvironmentVariableReferencesInFile(filePath) {
3842
3837
  const fileContents = await readFile2(filePath, "utf-8");
3843
3838
  return findAllEnvironmentVariableReferences(fileContents);
3844
3839
  }
3845
- var IGNORED_ENV_VARS = ["NODE_ENV", "SHELL", "HOME", "PWD", "LOGNAME", "USER", "PATH"];
3840
+ var IGNORED_ENV_VARS = ["NODE_ENV", "SHELL", "HOME", "PWD", "LOGNAME", "USER", "PATH", "DEBUG"];
3846
3841
  function findAllEnvironmentVariableReferences(code) {
3847
3842
  const regex = /\bprocess\.env\.([a-zA-Z_][a-zA-Z0-9_]*)\b/g;
3848
3843
  const matches = code.matchAll(regex);
@@ -4479,9 +4474,13 @@ async function devCommand(dir, options) {
4479
4474
  const authorization = await isLoggedIn(options.profile);
4480
4475
  if (!authorization.ok) {
4481
4476
  if (authorization.error === "fetch failed") {
4482
- logger.error("Fetch failed. Platform down?");
4477
+ logger.log(
4478
+ `${chalkError(
4479
+ "X Error:"
4480
+ )} Connecting to the server failed. Please check your internet connection or contact eric@trigger.dev for help.`
4481
+ );
4483
4482
  } else {
4484
- logger.error("You must login first. Use `trigger.dev login` to login.");
4483
+ logger.log(`${chalkError("X Error:")} You must login first. Use the \`login\` CLI command.`);
4485
4484
  }
4486
4485
  process.exitCode = 1;
4487
4486
  return;
@@ -4708,7 +4707,11 @@ function useDev({
4708
4707
  __PROJECT_CONFIG__: JSON.stringify(config)
4709
4708
  },
4710
4709
  plugins: [
4711
- bundleDependenciesPlugin(config),
4710
+ bundleDependenciesPlugin(
4711
+ "workerFacade",
4712
+ (config.dependenciesToBundle ?? []).concat([/^@trigger.dev/]),
4713
+ config.tsconfigPath
4714
+ ),
4712
4715
  workerSetupImportConfigPlugin(configPath),
4713
4716
  {
4714
4717
  name: "trigger.dev v3",
@@ -4901,8 +4904,11 @@ function WebsocketFactory(apiKey) {
4901
4904
  }
4902
4905
  async function gatherRequiredDependencies2(outputMeta, config) {
4903
4906
  const dependencies2 = {};
4907
+ logger.debug("Gathering required dependencies from imports", {
4908
+ imports: outputMeta.imports
4909
+ });
4904
4910
  for (const file of outputMeta.imports) {
4905
- if (file.kind !== "require-call" || !file.external) {
4911
+ if (file.kind !== "require-call" && file.kind !== "dynamic-import" || !file.external) {
4906
4912
  continue;
4907
4913
  }
4908
4914
  const packageName = detectPackageNameFromImportPath(file.path);
@@ -4945,14 +4951,12 @@ async function gatherRequiredDependencies2(outputMeta, config) {
4945
4951
  function createDuplicateTaskIdOutputErrorMessage(duplicateTaskIds, taskResources) {
4946
4952
  const duplicateTable = duplicateTaskIds.map((id) => {
4947
4953
  const tasks = taskResources.filter((task) => task.id === id);
4948
- return `id "${chalkPurple(id)}" was found in:
4949
- ${tasks.map((task) => `${task.filePath} -> ${task.exportName}`).join("\n")}`;
4950
- }).join("\n\n");
4951
- return `Duplicate task ids detected:
4952
-
4953
- ${duplicateTable}
4954
+ return `
4954
4955
 
4955
- `;
4956
+ ${chalkTask(id)} was found in:${tasks.map((task) => `
4957
+ ${task.filePath} -> ${task.exportName}`).join("")}`;
4958
+ }).join("");
4959
+ return `Duplicate ${chalkTask("task id")} detected:${duplicateTable}`;
4956
4960
  }
4957
4961
  function gatherProcessEnv() {
4958
4962
  const env = {