feat(builder): support ESM bundle options#7201
Open
TorinAsakura wants to merge 6 commits into
Open
Conversation
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.
What's the problem this PR addresses?
Closes #7200.
builder build bundlecurrently hardcodes an IIFE bundle format and a Node-engine-derived target. It also doesn't expose a way to keep selected dependencies external at bundle time.This makes ESM-only Yarn-based runtimes patch
@yarnpkg/builderglobally instead of using the official builder surface.How did you fix it?
Added opt-in
build bundleoptions for the bundle settings that downstream runtimes need:--format, defaulting to the existingiifebehavior;--target, defaulting to the existing Node target;--externalentries passed to esbuild.When
--format esmis selected, the bundle banner also installs the small Node compatibility setup needed by existing bundle code paths that expectrequire,__filename, and__dirname.The default
builder build bundlebehavior remains unchanged.Local checks run:
yarn workspace @yarnpkg/builder prepackyarn typecheck:all --pretty falseyarn version checkyarn node packages/yarnpkg-builder/sources/boot-cli-dev.js build bundle --helpChecklist
I have read the Contributing Guide.
I have set the packages that need to be released for my changes to be effective.
I will check that all automated PR checks pass before the PR gets reviewed.