Skip to content

Migrate JS to ESM only#42132

Open
mdo wants to merge 9 commits intov6-devfrom
v6-esm
Open

Migrate JS to ESM only#42132
mdo wants to merge 9 commits intov6-devfrom
v6-esm

Conversation

@mdo
Copy link
Member

@mdo mdo commented Mar 8, 2026

This is a big one and I had help doing it. Intention here was to eliminate some overhead on our JS side and lean towards the more modern approach of using native ES modules instead of UMD. Every browser, bundler, and Node.js version we support handles ESM natively.

Need to walk through the changes once more before merging. Fixes #31944. Updates a few things to also make things tree shakeable, fixes #37733.


What changed

Entry points:

  • Deleted js/index.umd.js and js/index.esm.js
  • Created js/index.js as the single ESM entry point for all builds

Build config (build/rollup.config.mjs):

  • Removed ESM environment variable toggle — format is always esm
  • Removed globals map and UMD name property (UMD-only concepts)
  • Added vanilla-calendar-pro to externals list (peer dep, shouldn't be bundled)
  • Fixed BUNDLE mode to use splice instead of fragile pop for removing Floating UI from externals

Plugin build (build/build-plugins.mjs):

  • Changed format: 'umd' to format: 'esm'
  • Removed globals, name, and className — ESM plugins preserve import/export statements as-is
  • Simplified external to () => true

package.json:

  • Replaced main/module with "type": "module" and an "exports" map with subpath exports
  • Merged js-compile-standalone and js-compile-standalone-esm into one script
  • Merged js-minify-standalone and js-minify-standalone-esm into one script
  • Updated integration test script paths to .mjs
  • Updated karma/jasmine config paths to .cjs
  • Removed jspm config (UMD-era artifact)
  • Removed @rollup/plugin-commonjs dependency (only needed for UMD plugin imports)
  • Updated files array

CJS config files renamed to .cjs (required by "type": "module"):

  • .babelrc.js.babelrc.cjs
  • js/tests/karma.conf.jsjs/tests/karma.conf.cjs
  • js/tests/browsers.jsjs/tests/browsers.cjs
  • scss/tests/jasmine.jsscss/tests/jasmine.cjs
  • scss/tests/sass-true/runner.jsscss/tests/sass-true/runner.cjs
  • scss/tests/sass-true/register.jsscss/tests/sass-true/register.cjs

Integration tests:

  • Rewrote rollup.bundle.js and rollup.bundle-modularity.js as ESM (.mjs)
  • Dropped @rollup/plugin-commonjs (no longer needed)
  • Updated bundle.js to import from bootstrap.js instead of bootstrap.esm.js
  • Updated bundle-modularity.js to import ESM plugins with .js extensions

Docs (javascript.mdx):

  • Removed all UMD references and bootstrap.esm.* naming
  • Removed es-module-shims polyfill recommendation (import maps are baseline now)
  • Simplified the ESM usage section
  • Added example showing individual component imports without any import map

Other:

  • Updated .bundlewatch.config.json — removed old UMD and .esm. entries
  • Updated README.md dist file listing
  • Deleted stale dist/js/bootstrap.esm.* files

@mdo mdo requested a review from a team as a code owner March 8, 2026 17:20
@mdo mdo added this to v6.0.0 Mar 8, 2026
@github-project-automation github-project-automation bot moved this to Inbox in v6.0.0 Mar 8, 2026
@XhmikosR

This comment was marked as resolved.

@mdo mdo requested a review from a team as a code owner March 9, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

2 participants