Repository navigation
Fix #8558: added ESM builds to fix 'require is not defined' via jsDelivr +esm - #8559
Merged
Merged
Conversation
wenzhixin
force-pushed
the
new/issue-8558-esm-fix
branch
from
November 4, 2026 10:54
209c985 to
d633aeb
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The ESM build injects only $, leaving search code dependent on a global jQuery and causing a ReferenceError when that global is absent.
1 open issue
What changed in this PR
Adds native ESM builds to address the require is not defined error reported in #8558 when Bootstrap Table is loaded through jsDelivr’s +esm endpoint.
Changes:
- Generates ESM outputs alongside existing UMD builds for core, extensions, themes, and locales.
- Adds a package
moduleentry pointing ESM-aware consumers to the minified ESM build. - Corrects filename replacement patterns to match literal
.jssuffixes.
| File | Description |
|---|---|
rollup.config.js |
Adds ESM outputs for development and production builds while retaining UMD outputs. |
package.json |
Declares the minified ESM bundle through the module field. |
Review effort: Balanced
…ivr +esm - Add an 'es' format output for every rollup entry (core, extensions, themes, locales), producing .esm.js / .esm.min.js files with a top-level 'import $ from "jquery"' that ESM pipelines can resolve - Add 'module' field to package.json so ESM-aware resolvers (jsDelivr +esm, bundlers) pick the ESM build instead of converting the UMD one
wenzhixin
force-pushed
the
new/issue-8558-esm-fix
branch
from
November 4, 2026 14:36
d633aeb to
1e69866
Compare
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.

**🤔Type of Request
🔗Resolves an issue?
Fix #8558
📝Changelog
Core
Extensions
Update: Added ESM builds (
.esm.js/.esm.min.js) and amodulefield inpackage.jsonto fixrequire is not definedwhen the package is consumed via jsDelivr's+esmendpoint (e.g. Symfony AssetMapper importmap).💡Example(s)?
Not applicable — no API/behavior change from the user side. Before/after of the jsDelivr
+esmoutput:Before (UMD entry converted, bare
requirethrows in browser):After (ESM entry used directly):
☑️Self Check before Merge
⚠️ Please check all items below before reviewing. ⚠️
Root cause & verification details
The npm package ships UMD-only entries (
main: dist/bootstrap-table.min.js). When jsDelivr's+esmservice converts the UMD file, therequire("jquery")inside the UMD conditional (typeof exports === 'object' ? ... require('jquery') ...) cannot be statically detected and rewritten. The converted module keeps a barerequirecall, and since jquery is a peerDependency noimportshim is injected for it — the browser then throws when the CJS branch is activated by the jsDelivr wrapper. Older versions re-converted through the current jsDelivr pipeline fail the same way; 1.28.0 just surfaced it.Solution:
esformat output for every rollup entry (core, extensions, themes, locales) →.esm.js/.esm.min.jsfiles with a top-levelimport $ from 'jquery'that any ESM pipeline can resolve and rewrite correctly."module": "dist/bootstrap-table.esm.min.js"to package.json so ESM-aware resolvers (jsDelivr+esm, bundlers) pick the real ESM build instead of converting the UMD one.jQuery: 'jquery'alongside$in the rollupinject()plugin, so the barejQueryidentifier used in the search module resolves to the imported jquery instance instead of an implicit global (window.jQuery) — without a globaljQuery, typing in the search field previously threwReferenceErrorin ESM consumers.dist/artifacts are rebuilt at release time (per repo convention, they are not part of feature PRs).Verification (built locally, artifacts not committed):
dist/bootstrap-table.esm.min.jsstarts withimport t from"jquery", exportsBootstrapTableas default, no UMD wrapper / no barerequireinstanceof jQueryremains in any ESM output (rewritten to the imported$binding); UMD output unchanged semanticallyVERSION: 1.28.0,DEFAULTSpresent)npm run test:vitest: 489 tests passed