Skip to content

feat(builder): support ESM bundle options#7201

Open
TorinAsakura wants to merge 6 commits into
yarnpkg:masterfrom
TorinAsakura:feat/builder-esm-bundle-options
Open

feat(builder): support ESM bundle options#7201
TorinAsakura wants to merge 6 commits into
yarnpkg:masterfrom
TorinAsakura:feat/builder-esm-bundle-options

Conversation

@TorinAsakura

Copy link
Copy Markdown

What's the problem this PR addresses?

Closes #7200.

builder build bundle currently 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/builder globally instead of using the official builder surface.

How did you fix it?

Added opt-in build bundle options for the bundle settings that downstream runtimes need:

  • --format, defaulting to the existing iife behavior;
  • --target, defaulting to the existing Node target;
  • repeatable --external entries passed to esbuild.

When --format esm is selected, the bundle banner also installs the small Node compatibility setup needed by existing bundle code paths that expect require, __filename, and __dirname.

The default builder build bundle behavior remains unchanged.

Local checks run:

  • yarn workspace @yarnpkg/builder prepack
  • yarn typecheck:all --pretty false
  • yarn version check
  • yarn node packages/yarnpkg-builder/sources/boot-cli-dev.js build bundle --help

Checklist

  • 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.

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.

[Feature] Support ESM bundle output and externals in @yarnpkg/builder

1 participant