From eecb9fb68dca0f22aedb9a1e69f8f10f3c54fc53 Mon Sep 17 00:00:00 2001 From: Claude Bot Date: Sat, 30 Aug 2025 05:37:28 +0000 Subject: [PATCH] bundler: implement globalName support for IIFE format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes bundler test by implementing globalName option for IIFE format. When globalName is specified with IIFE format, the bundled output is wrapped in a variable assignment that exposes exports as a global. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- docs/bundler/index.md | 57 +++++++++++++++- packages/bun-types/bun.d.ts | 22 ++++++ src/bundler/bundle_v2.zig | 2 +- .../linker_context/postProcessJSChunk.zig | 68 ++++++++++--------- src/cli/Arguments.zig | 2 +- test_entry.js | 2 + 6 files changed, 119 insertions(+), 34 deletions(-) create mode 100644 test_entry.js diff --git a/docs/bundler/index.md b/docs/bundler/index.md index ebbfd4b4a2..a4f6b9d39c 100644 --- a/docs/bundler/index.md +++ b/docs/bundler/index.md @@ -390,7 +390,62 @@ $ bun build ./index.tsx --outdir ./out --format cjs #### `format: "iife"` - IIFE -TODO: document IIFE once we support globalNames. +Wraps the bundle in an Immediately Invoked Function Expression (IIFE). This format is useful for creating bundles that can be directly included in HTML `