Skip to content

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

@webketje

Description

@webketje

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions