jason810496 opened a new pull request, #73126:
URL: https://github.com/apache/airflow/pull/73126
- related: #69905
- follow-up to review comments on #72046
- **next**: stacked PR for the embedded entrypoint source
## Why
`NodeCoordinator` looked for exactly `bundle.mjs` in each configured root,
so a `bundles_root` could hold only one bundle and its name was fixed, which
defeats the Dag-to-bundle routing the embedded metadata already supports.
## How
- Search each root recursively for `*.min.mjs` and select on metadata, the
way `JavaCoordinator` walks for `*.jar` and `ExecutableCoordinator` walks for
executables.
- Roots in configured order, each directory's entries in sorted path
order, so which bundle wins no longer depends on the order a filesystem returns
entries in.
- Directories deduplicated by `(st_dev, st_ino)`, so a symlink loop
terminates the walk.
- Minify the esbuild output. An integrity digest over the code region is
only worth taking when the artifact is not something anyone is expected to read
or edit in place, which is what `.min` records.
- `keepNames` preserves identifier names so handler names still appear in
the stack traces a failing task reports.
- `legalComments` is left at its default, so bundled dependencies keep
their `/*! */` license banners.
- The `.mjs` half of the suffix is load-bearing, not cosmetic. The bundle is
an ES module with top-level `await` and cannot fall back to CommonJS, while a
`.js` file is treated as an ES module only by Node's syntax detection, which is
unavailable before Node 22.7 and skipped outright when an enclosing
`package.json` declares `"type": "commonjs"`:
```
$ node probe.min.js # no package.json -> ran
$ echo '{"type":"commonjs"}' > package.json
$ node probe.min.js
SyntaxError: await is only valid in async functions and the top level
bodies of modules
$ node probe.min.mjs # same bytes -> ran
```
The bundle container format is unchanged. Minification only changes which
bytes land inside the already-digested code region.
## What
- `coordinators/node/coordinator.py`: replace `BUNDLE_FILENAME` with
`BUNDLE_SUFFIX = ".min.mjs"` and recursive discovery.
- `coordinators/_bundle_metadata.py`: add the shared `walk_files` helper.
`JavaCoordinator` and `ExecutableCoordinator` still carry their own equivalent
walks and should move onto it separately.
- `ts-sdk/src/cli/pack.ts`: emit a minified `bundle.min.mjs`, add
`--outfile`, reject `--outdir` together with `--outfile` and an `--outfile`
name that would be invisible to the coordinator.
- Docs: `ts-bundle-spec.rst` gains an "Artifact Name" section, plus
`typescript.rst`, `ts-sdk/README.md`, `ts-sdk/example/README.md`.
- E2E: the fixture bundle is deliberately copied under a different name to
exercise metadata-based routing.
- Tests: 12 new or rewritten cases covering suffix filtering, nested
bundles, several bundles in one root, sorted ordering, symlink loops, and an
unrelated `.min.mjs` landing in the rejection diagnostics.
## Verification
- `pytest task-sdk/tests/task_sdk/coordinators/` 174 passed
- `pnpm test` 245 passed, plus `typecheck`, `lint`, `format:check`
- `prek --stage pre-commit` and `--stage manual` clean, `mypy-task-sdk`
passed
- Cross-language: a minified `bundle.min.mjs` runs under `node` and passes
the Python reader's digest verification.
---
##### Was generative AI tooling used to co-author this PR?
- [x] Yes, with help of Claude Code Opus 5 following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]