Skip to content

docs: add esbuild bundling rules for require() in AGENTS.md#1011

Merged
BYK merged 1 commit into
mainfrom
docs/esbuild-rules
May 22, 2026
Merged

docs: add esbuild bundling rules for require() in AGENTS.md#1011
BYK merged 1 commit into
mainfrom
docs/esbuild-rules

Conversation

@BYK

@BYK BYK commented May 22, 2026

Copy link
Copy Markdown
Member

Documents the critical esbuild bundling rule that caused two post-migration bugs (#1008, #1009):

esbuild only statically resolves bare require() calls. Any aliased require (_require, localRequire, etc.) passes through as-is into the bundle and breaks at runtime when used with relative paths.

Adds a reference table and 4 key rules to AGENTS.md so AI agents and contributors avoid this pattern.

Filed #1010 for the companion testing improvements (deeper smoke tests for binary + npm bundle).

Document the critical rule that esbuild only resolves bare require() calls
statically. Aliased requires (_require, localRequire) pass through and break
in bundles when used with relative paths.

Also documents the correct pattern: use createRequire for node builtins and
npm packages only, keep bare require() for relative lazy imports.
@BYK BYK merged commit 70460bc into main May 22, 2026
24 checks passed
@BYK BYK deleted the docs/esbuild-rules branch May 22, 2026 20:32
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.

1 participant