I am currently facing an issue while trying to integrate the datatables JQuery plugin with webpack and typescript. While I have successfully set up JQuery with typings and intelliSense, the datatables integration seems to be causing issues. After building with webpack, the code fails at the $('#id').dataTable() line.
app.js:43Uncaught TypeError: $(...).dataTable is not a function
I am struggling to find the correct way to include this plugin. Can anyone offer some guidance?
Here is the webpack.config.js setup: https://gist.github.com/marcingolenia/2fa78ed2cd42f9294da5edd22d351245
I believe this line could potentially resolve the issue;
{ test: require.resolve("dataTables.net"), loader: "imports?define=>false,$=jquery"},
Referring to the documentation of the import loader;
Many modules check for a define function before using CommonJS. Since webpack supports both, they default to AMD, which might cause issues in certain implementations.
Since datatables supports both, I attempted to disable AMD using define=>false, as mentioned here
Unfortunately, I am currently stuck at this point.