feat: add bun target#21248
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 0c0d41f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
This PR is packaged and the instant preview is available (8ee5dc1). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@8ee5dc1
yarn add -D webpack@https://pkg.pr.new/webpack@8ee5dc1
pnpm add -D webpack@https://pkg.pr.new/webpack@8ee5dc1 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21248 +/- ##
==========================================
- Coverage 92.80% 92.80% -0.01%
==========================================
Files 590 591 +1
Lines 64626 64653 +27
Branches 17996 18009 +13
==========================================
+ Hits 59978 60002 +24
- Misses 4648 4651 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
4daa159 to
f76fc69
Compare
f76fc69 to
0c0d41f
Compare
Contributor
Types CoverageCoverage after merging claude/bun-target-support-n8wrx2 into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Summary
Adds a first-class
bunbuild target (target: "bun", with versions likebun1.1, resolved the same way asnode14.5). It emits ESM by default and is treated as a node platform, so it slots into the existing node externals/handling.Bun-specific behavior:
experiments.outputModuledefaults on (Bun consumes ESM), exactly like theuniversaltarget.fs), and Bun's ownbun:*built-ins (bun,bun:sqlite,bun:ffi, …) are kept external via a newexternalsPresets.bun/BunTargetPlugin.bunresolve condition is added;compiler.platform.bunis populated so plugins can detect the target.The default runtime intentionally uses the web-standard APIs Bun implements natively (
import(),fetch,import.meta.url) rather than proprietaryBun.*calls — this keeps it consistent with thedenotarget (#21247) and portable. Bun staysweb: false(server runtime, node-style resolution) so it does not pull in thebrowserresolve condition.What kind of change does this PR introduce?
feat
Did you add tests for your changes?
Yes.
test/Defaults.unittest.jsgains atarget: "bun"snapshot, andtest/configCases/target/bun/*covers thebunexport condition (runs in the Node integration suite), whiletest/configCases/target/bun-api/*exercises theBunglobal and externalizedbun:sqlite/node:osbuilt-ins (gated to the Bun runtime).Does this PR introduce a breaking change?
No. It only adds a new opt-in
targetvalue and a newexternalsPresets.bun.If relevant, what needs to be documented once your changes are merged or what have you already documented?
The
targetconfiguration docs should list the newbun/bun[X[.Y]]value, and the externals docs should mention theexternalsPresets.bunpreset.Use of AI
AI (Claude Code) was used to help map where target properties thread through
lib/, draft the implementation and tests, and keep the target in sync with thedenotarget (#21247). All changes were reviewed and validated locally (yarn lint,yarn tsc, targetedjestruns under both Node and Bun) before submitting.Generated by Claude Code