Repository navigation
Fix "Dynamic require" error for CommonJS packages in airflow-ts-pack - #75067
Merged
jason810496 merged 2 commits intoOct 25, 2026
Merged
Conversation
guan404ming
approved these changes
Oct 19, 2026
airflow-ts-pack outputs an ESM bundle, and an ESM file has no
`require`. esbuild turns a CommonJS dependency's `require("fs")` into
a shim that throws `Dynamic require of "fs" is not supported` unless a
`require` is in scope. So any Dag importing such a package (yaml, pg,
axios, @aws-sdk/client-s3, ...) failed to pack, and users cannot pass
esbuild options to work around it.
Andrushika
force-pushed
the
Andrushika/ts-package-problem
branch
from
October 21, 2026 12:53
2b206cb to
83a547d
Compare
jason810496
approved these changes
Oct 25, 2026
jason810496
left a comment
Member
There was a problem hiding this comment.
Nice catch, I verified locally, it's indeed a error we need to fix, thanks.
Contributor
Author
|
Hi @jason810496 could you please help rebase this? |
jason810496
disabled auto-merge
October 25, 2026 07:47
Contributor
Backport successfully created: v3-4-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
jason810496
pushed a commit
that referenced
this pull request
Oct 25, 2026
…low-ts-pack (#75067) (#75603) * Fix airflow-ts-pack for CommonJS packages using Node built-ins airflow-ts-pack outputs an ESM bundle, and an ESM file has no `require`. esbuild turns a CommonJS dependency's `require("fs")` into a shim that throws `Dynamic require of "fs" is not supported` unless a `require` is in scope. So any Dag importing such a package (yaml, pg, axios, @aws-sdk/client-s3, ...) failed to pack, and users cannot pass esbuild options to work around it. * Move the require banner comment onto the esbuild option (cherry picked from commit 8b2ef80) Co-authored-by: Andrew Chang <69671930+Andrushika@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
airflow-ts-packbundles a TypeScript Dag into one ESM file with esbuild, then runs that file once to read its Dags. When a dependency ships CommonJS for Node, esbuild turns itsrequire("fs")into a shim that throws if norequireis in scope, and an ESM file has none. So pack fails withDynamic require of "fs" is not supportedfor any Dag that imports such a package. On main, 9 of the 15 common packages I tried fail this way, includingyaml,pg,axios,@aws-sdk/client-s3anddotenv. Users cannot pass esbuild options toairflow-ts-pack, so they cannot work around it.What
Add an esbuild banner that defines
requirewithcreateRequire(import.meta.url), the usual workaround from evanw/esbuild#1921. With it, all 15 packages pack and run.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5.5) following the guidelines