Skip to content

feat(browser-bundle): add IIFE browser bundle for CDN/iframe embedding#469

Open
vishxrad wants to merge 4 commits intomainfrom
visharad/browser-bundle
Open

feat(browser-bundle): add IIFE browser bundle for CDN/iframe embedding#469
vishxrad wants to merge 4 commits intomainfrom
visharad/browser-bundle

Conversation

@vishxrad
Copy link
Copy Markdown
Member

Summary

  • Adds a new package @openuidev/browser-bundle: a prebuilt IIFE bundle of @openuidev/react-lang + @openuidev/react-ui (with React, ReactDOM, and all runtime deps inlined) plus a combined stylesheet, intended for iframe, CDN, and no-build-pipeline contexts (Open WebUI tool plugins, embeddable chat widgets, static-site demos, CodePen-style prototypes).
  • Exposes a single stable global: window.__OpenUI = { React, createRoot, Renderer, openuiChatLibrary }. Changes to this shape are considered breaking and will bump the major version.
  • Build pipeline: esbuild for the JS bundle + a small Node script that resolves @openuidev/react-ui via createRequire and concatenates its two CSS files into dist/openui-styles.css (works regardless of pnpm hoisting).
  • Registers browser-bundle as an option in .github/workflows/publish-npm-package.yml so it can be released via the existing manual-dispatch flow.

For any project with a real build pipeline, consumers should keep using @openuidev/react-lang and @openuidev/react-ui directly — this package only exists for environments that can't do module resolution.

Adds @openuidev/browser-bundle, a prebuilt IIFE bundle of
@openuidev/react-lang + @openuidev/react-ui (plus their runtime deps)
and a combined stylesheet, for use in iframe, CDN, and no-build-pipeline
contexts (Open WebUI tool plugins, embeddable widgets, CodePen-style
demos). Exposes a single stable window.__OpenUI global.

Also registers the package in the publish-npm-package workflow so it
can be released via the existing manual dispatch flow.

Made-with: Cursor
react-ui's "exports" field doesn't expose "./package.json", so
require.resolve("@openuidev/react-ui/package.json") was falling through
to the "./*" wildcard and mis-resolving to dist/components/package.json,
which broke `prepare` in CI. Resolve the two stylesheets directly via
the declared "./defaults.css" and "./components.css" subpath exports
instead.

Also quote `--define:process.env.NODE_ENV='"production"'` in the build
script so esbuild sees a string literal and properly DCEs React's dev
branches (bundle shrinks from 2.6 MB to 2.2 MB).

Made-with: Cursor
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.

1 participant