Skip to content

Add airflow-ts-pack bundle build tool for TypeScript SDK#69295

Merged
jason810496 merged 4 commits into
apache:mainfrom
guan404ming:ts-pack-cli
Jul 16, 2026
Merged

Add airflow-ts-pack bundle build tool for TypeScript SDK#69295
jason810496 merged 4 commits into
apache:mainfrom
guan404ming:ts-pack-cli

Conversation

@guan404ming

@guan404ming guan404ming commented Jul 3, 2026

Copy link
Copy Markdown
Member

Related Issue

close #69286

Why

TypeScript SDK users had to run esbuild by hand and hand-write the airflow-metadata.yaml sidecar, which could drift from the bundle.

How

  • Add airflow-ts-pack CLI that bundles a TypeScript entrypoint with esbuild and embeds the Airflow metadata into bundle.mjs as a trailing //# airflowMetadata=<base64> comment, producing a single deployable artifact
  • Add --airflow-metadata dump mode to startCoordinator() so the manifest comes from the bundle's own task registry, never hand-written
  • Update NodeCoordinator to read embedded metadata first, falling back to the airflow-metadata.yaml sidecar for compatibility

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    Claude Code with Fable 5

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@guan404ming
guan404ming marked this pull request as ready for review July 3, 2026 10:31

@jason810496 jason810496 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! Would like to know more about the design choice before going down the implementation details.

Comment thread task-sdk/src/airflow/sdk/coordinators/node/coordinator.py
Comment thread task-sdk/tests/task_sdk/coordinators/node/test_coordinator.py Outdated
Comment thread ts-sdk/example/package.json
@guan404ming
guan404ming force-pushed the ts-pack-cli branch 2 times, most recently from 4583f0e to 9031129 Compare July 4, 2026 08:43
@guan404ming
guan404ming requested a review from jason810496 July 8, 2026 04:13

@jason810496 jason810496 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice! Thanks for the follow-up and sorry that I didn't think about the trailer design decision in the first place.

https://github.com/apache/airflow/pull/69295/changes#r3551043871 is the only comment from me. Rest of them are nits raise by CC, please feel free to push back if the comment doesn't make sense to you. Thanks!

Comment thread ts-sdk/src/cli/pack.ts Outdated
Comment thread ts-sdk/src/cli/pack.ts Outdated
Comment thread ts-sdk/package.json
Comment thread ts-sdk/src/cli/pack.ts Outdated
Comment thread ts-sdk/src/cli/pack.ts Outdated
Comment thread ts-sdk/src/cli/pack.ts
Comment thread task-sdk/src/airflow/sdk/coordinators/node/coordinator.py
@shivaam

shivaam commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@jason810496 Could we hold off on merging this until I finish reviewing it? This PR defines an important user-facing build and packaging workflow, and I want to ensure it fits well with existing TypeScript projects.

@guan404ming guan404ming self-assigned this Jul 10, 2026
@jason810496

Copy link
Copy Markdown
Member

@jason810496 Could we hold off on merging this until I finish reviewing it? This PR defines an important user-facing build and packaging workflow, and I want to ensure it fits well with existing TypeScript projects.

Sure, we still have some buffer to wait for review. I target to merge this one at the beginning of next week (Mon or Tue).

@shivaam

shivaam commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Not a blocker and can be done later if you want.
One thing I am thinking is that the one command workflow looks good for simple TypeScript projects. My main concern is that airflow-ts-pack always rebuilds the entrypoint using its own esbuild configuration.

Projects or teams may use Vite, webpack, or custom esbuild plugins and settings. Could we add a packaging-only mode for an existing .mjs artifact?

pnpm vite build
pnpm exec airflow-ts-pack --bundle dist/airflow.mjs

In this mode, ts-pack would not compile the code again. It would only run the bundle’s metadata introspection and embed the Airflow metadata. We can keep the simple command as the default option and the packaging only mode can be the second option. The only requirement on the user's build output is that the .mjs is a single file node can run directly, with all dependencies bundled inside.

Comment thread task-sdk/src/airflow/sdk/coordinators/node/coordinator.py Outdated
Comment thread ts-sdk/src/cli/pack.ts Outdated
Comment thread task-sdk/src/airflow/sdk/coordinators/node/coordinator.py
Comment thread task-sdk/src/airflow/sdk/coordinators/node/coordinator.py Outdated
Comment thread ts-sdk/src/coordinator/runtime.ts Outdated
Address review: strip entry shebangs so the metadata line stays first,
read the manifest via a sentinel line immune to import-time logging,
validate before writing bundle.mjs, make esbuild an optional peer
dependency, and reject null dags manifests.
@guan404ming

Copy link
Copy Markdown
Member Author

I like this idea. One small note: introspection needs the artifact to reach startCoordinator() on startup to answer --airflow-metadata, so the requirement is slightly stronger than "a single .mjs node can run", worth spelling out in the docs. Would like to do this in a follow-up.

@shivaam

shivaam commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

I like this idea. One small note: introspection needs the artifact to reach startCoordinator() on startup to answer --airflow-metadata, so the requirement is slightly stronger than "a single .mjs node can run", worth spelling out in the docs. Would like to do this in a follow-up.

sounds good

@shivaam shivaam left a comment

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.

Thanks for addressing the comments. Looks good.

@jason810496
jason810496 merged commit 8f1838c into apache:main Jul 16, 2026
107 checks passed
joshuabvarghese pushed a commit to joshuabvarghese/airflow that referenced this pull request Jul 16, 2026
* Add airflow-ts-pack bundle build tool for TypeScript SDK

* Embed TypeScript bundle metadata as leading comment

* Harden airflow-ts-pack manifest reading and packaging

Address review: strip entry shebangs so the metadata line stays first,
read the manifest via a sentinel line immune to import-time logging,
validate before writing bundle.mjs, make esbuild an optional peer
dependency, and reject null dags manifests.

* Validate embedded metadata size and split manifest out of runtime
@jason810496 jason810496 moved this from Backlog to Done in TS-SDK Jul 20, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in TS-SDK Jul 20, 2026
@jason810496 jason810496 added this to the TS SDK 1.0 Beta milestone Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

TypeScript SDK: add a ts pack bundle build tool

3 participants