Sitelet https://github.com/tangle-network/agent-integrations/pull/266
Skip to content

fix(connectors): make the native specifiers opaque to a bundler - #266

Merged
drewstone merged 1 commit into
mainfrom
fix/worker-opaque-native-specifier
Aug 9, 2026
Merged

drewstone merged 1 commit into
mainfrom
fix/worker-opaque-native-specifier

Conversation

@drewstone

Copy link
Copy Markdown
Contributor

#264 was necessary and not sufficient. Moving both native clients behind await import() does not remove them from a bundle: a bundler resolves a literal dynamic import exactly like a static one — it moves the module into its own chunk and still has to load duckdb.node.

Measured on legal-agent against the published 0.53.42:

[UNLOADABLE_DEPENDENCY] … @duckdb/node-bindings-linux-x64/duckdb.node
[UNRESOLVED_IMPORT]     … cpu-features/build/Release/cpufeatures.node
Build failed

The static graph from /catalog + /specs was already clean at that version — the walk proves it — and the build still failed, which is the whole lesson: a clean static graph is not the same as a bundle that links.

The specifier is now assembled at runtime, so no bundler can read it and the import is left to the runtime. Node resolves it; a Worker bundle never sees it.

Proven on the real consumer before publishing: patching the same transformation into legal-agent's installed 0.53.42 copy turned its build from the two errors above to ✓ built in 4.86s / ✓ built in 6.35s.

Guard

src/worker-safe-subpaths.test.ts now fails on a literal dynamic import as well as a static one, and strips comments first — the prose explaining the rule was otherwise reported as a breach of it:

+   "connectors/adapters/duckdb.ts dynamically imports the literal @duckdb/node-api"
  Tests  2 failed | 1 passed (3)

typeof import('…') is excluded by lookbehind: a type query erases, which is how both adapters keep full typing while loading through an opaque specifier.

Suite: 686 files / 5,161 tests passed. pnpm typecheck exit 0, pnpm build exit 0. Version bumped to 0.53.43 in the same change.

0.53.42 moved both native clients behind await import(), which is not enough: a
bundler resolves a LITERAL dynamic import exactly like a static one. It moves
the module into its own chunk and still has to load duckdb.node. Measured on
legal-agent, whose Worker build failed on the same two files after the lazy
change.

The specifier is now assembled at runtime, so a bundler cannot read it and
leaves the import to the runtime. Node resolves it; a Worker bundle never sees
it. The guard test now fails on a literal dynamic import too, and strips
comments first so the sentence explaining the rule is not read as a breach of
it.
@drewstone
drewstone merged commit 8ad628e into main Aug 9, 2026
@drewstone
drewstone deleted the fix/worker-opaque-native-specifier branch August 9, 2026 23:59

@tangletools tangletools left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

✅ Auto-approved drewstone PR — d62b9354

This PR was opened by the trusted drewstone account.
The full PR reviewer audit still runs separately and will publish findings if it detects issues.

tangletools · auto-approval · reason: drewstone_author · 2026-08-09T23:59:40Z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants