DataTables / DataTables/Responsive

Bug: bootstrap5 ESM/ non-jQuery initialization crashes due to Responsive plugin

Open
#127 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
151
Forks
91
PR merge metrics
No merged PRs in 30d

Description

When imported in an NPM package context as instructed in https://datatables.net/download/npm#ES-module-loader:

import DataTable from 'datatables.net-bs5'
import 'datatables.net-responsive-bs5'

this line https://github.com/DataTables/Responsive/blob/3.0.0/js/responsive.bootstrap5.js#L5 fails due to error:

Uncaught TypeError: dataTables_bootstrap5_default.Responsive is undefined
    mjs responsive.bootstrap5.mjs:13
    __init app.js:38
    js TransactionsTable.js:2
    __init app.js:38
    js index.js:1
    __require app.js:41
    <anonymous> app.js:42837
    <anonymous> app.js:42838

My guess is that this is because here:
https://github.com/DataTables/Responsive/blob/3.0.0/js/dataTables.responsive.js#L1719
Responsive is only added to $.fn.DataTable and $.fn.dataTable, but not to DataTable and that this may work in a global browser window context somehow, but fails when using an ESM bundler.

I have not tested extensively but this issue may also be present for other integrations

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the NPM ESM setup shown in the issue, starting with responsive.bootstrap5.js around line 5. Then inspect dataTables.responsive.js around line 1719 and compare the exports used by the Bootstrap 5 integration. Done means the non-jQuery Bootstrap 5 ESM initialization no longer throws the reported Responsive error; check whether the same issue affects other integrations.

Written by the indexing model from the issue text.

Assessment

Tech stack
bootstrap, javascript, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.