Skip to content

fix: update CDN bundle configurations, enable setTheme on globalThis#36113

Open
chrisdholt wants to merge 9 commits intomicrosoft:masterfrom
chrisdholt:users/chhol/migrate-to-esbuild-for-bundle-fix-theme-exports
Open

fix: update CDN bundle configurations, enable setTheme on globalThis#36113
chrisdholt wants to merge 9 commits intomicrosoft:masterfrom
chrisdholt:users/chhol/migrate-to-esbuild-for-bundle-fix-theme-exports

Conversation

@chrisdholt
Copy link
Copy Markdown
Member

@chrisdholt chrisdholt commented May 7, 2026

Previous Behavior

Rollup was used to compile a single bundle for everything, setTheme was not available as an export.

New Behavior

  1. setTheme is available for use by assigning it to globalThis.

  2. This change now enables the distribution of two bundles both uncompressed and minified:

  • web-components-all.js => Everything from the package re-exported. This previously was the only export.
  • web-components.js => Just the side-effectful definitions and setTheme (this is the new default and the primary use case )

By way of touching related files, this PR also removes the deprecated setThemeFor utility as setTheme supports the behavior.

Related Issue(s)

  • Fixes #

@chrisdholt chrisdholt requested review from a team as code owners May 7, 2026 06:51
@chrisdholt chrisdholt force-pushed the users/chhol/migrate-to-esbuild-for-bundle-fix-theme-exports branch from be4e4ff to 277ec77 Compare May 7, 2026 06:55
@chrisdholt chrisdholt force-pushed the users/chhol/migrate-to-esbuild-for-bundle-fix-theme-exports branch 3 times, most recently from 07aebe7 to d70f3fc Compare May 7, 2026 07:04
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

📊 Bundle size report

✅ No changes found

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Pull request demo site: URL

@chrisdholt chrisdholt changed the title fix: migrate to esbuild for CDN bundle, enable setTheme on globalThis fix: update CDN bundle configurations, enable setTheme on globalThis May 7, 2026
@chrisdholt chrisdholt force-pushed the users/chhol/migrate-to-esbuild-for-bundle-fix-theme-exports branch from 3ef91a5 to c00ef25 Compare May 7, 2026 18:45
@chrisdholt chrisdholt force-pushed the users/chhol/migrate-to-esbuild-for-bundle-fix-theme-exports branch from a1ccd24 to 68f7a07 Compare May 7, 2026 18:50
@chrisdholt chrisdholt enabled auto-merge (squash) May 7, 2026 20:46
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of duplicating all of the define imports, they could be moved to a define-all.ts and that module could be imported in both modules


// Expose setTheme on globalThis for CDN/script-tag consumers
// @ts-expect-error - CDN bundle intentionally sets globals
globalThis.setTheme = setTheme;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we worry about setTheme being too generic on globalThis?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants