1

I'm trying to switch from a requirejs config to a webpack one and am having trouble to make yadcf work.

In my packages.json :

{
  ...
  "dependencies": {
    ...
    "datatables.net": "^1.10.12",
    "datatables.net-bs": "^1.10.12",
    "jquery": "^3.1.1",
    "yadcf-npm": "^0.8.9"
  }
}

My webpack.config.js :

...
resolve: {
  alias: {
    ...
    datatables: path.join(__dirname, 'node_modules/datatables.net/js/jquery.dataTables'),
    datatablesBootstrap: path.join(__dirname, 'node_modules/datatables.net-bs/js/dataTables.bootstrap'),
    yadcf: path.join(__dirname, 'node_modules/yadcf-npm/jquery.dataTables.yadcf.js'),
  }
}

my script :

define(['jquery', 'datatablesBootstrap', 'yadcf'], function($) {
    $(document).ready(function(){
        ...
        var myDatatable = dataTable = $('#elem').DataTable({
            ...
        });

        myDatatable.yadcf([
            ...
        ]);
    });
});

I keep having the same issue where yadcf is not defined

Uncaught ReferenceError: yadcf is not defined(…)

Do you know what I'm missing here ?

Gyrocode.com
  • 57,606
  • 14
  • 150
  • 185
jiboulex
  • 2,963
  • 2
  • 18
  • 28

1 Answers1

2

You should use yadcf v0.9.1 , since the support for AMD / CommonJS was added in this release and it should work with Webpack too, you can get it from npm or from github or bower...

Daniel
  • 36,833
  • 10
  • 119
  • 200
  • Oh my god I swear I tested with this version but I must have left yadcf-npm in my webpack config file when I did. This time I updated the webpack config as well and it worked ! Thank you sir. – jiboulex Dec 06 '16 at 14:22