Topic: Vendor modules aren't added using brunch

auxhub free asked 5 years ago


Expected behavior After I install MBP-pro via npm the modules and components should work when I add the required classes and/or initializers

Actual behavior Components like the range-input aren't loaded into vendor.js unless manually required in app.js

require('mdbootstrap-pro/js/modules/range-input');

and vendor modules like datatables and velocity are also not loaded even after the modules are added, so also need to be required individually which means seeing what breaks and then adding files one at a time until it's no longer broken. eg

$ npm install datatables.net
require('datatables.net');

Piotr Glejzer staff answered 5 years ago


Hello,
I already fixed this issue. You have to change in picker.js ( or in mdb.js ) code below

  // AMD.
  if (typeof define == 'function' && define.amd)
    define(['./picker', 'jquery'], factory)

  // Node.js/browserify.
  else if (typeof exports == 'object')
    module.exports = factory(require('./picker.js'), require('jquery'))

to:

  // AMD.
  if ( typeof define == 'function' && define.amd )
      define( 'picker', ['jquery'], factory )

  // Node.js/browserify.
  else if ( typeof exports == 'object' )
      module.exports = factory( require('jquery') )

It should work. It will be fixed globally in the next release.


auxhub free answered 5 years ago


Thanks Anna

That does appear to be the problem, but my issue is that this should not be the case, and it doesn't make sense to have files scattered through my project folder when all the modules are installed and managed by npm and brunch.

If this is a limitation of mdb-pro, then could you please arrange a refund and I'll find a different library that does work for me.


Filip Kapusta premium commented 5 years ago

Hello, I reached to you on your email address ;)

Please respond so we could make this happen

If you need anything else please let me know.

Best regards, Filip from MDB


Anna Morawska staff answered 5 years ago


Hi there,

it's probably because of this line in mdb.js file:

....
    // Node.js/browserify.
      else if (typeof exports == 'object')
        module.exports = factory(require('./picker.js'), require('jquery'))
....

In this case, the easiest option is to attach this file to your project.


auxhub free answered 5 years ago


Hi Anna

Thanks for the response,

Unfortunately I still receive an error

error: Processing of node_modules/mdbootstrap-pro/js/mdb.js failed. Error: Could not load module './picker.js'

when requiring mdb.js. I can see that picker.js like datatables.js and velocity.js is included in the repo for mdb-pro, but it doesn't seem to be loaded by brunch.


Anna Morawska staff answered 5 years ago


Hi there,

you can use mdb.js - that file merges all required modules together.

require('mdbootstrap-pro/js/mdb.js')

Best,

Ania



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.7.7
  • Device: MBP
  • Browser: Chrome
  • OS: OSX
  • Provided sample code: No
  • Provided link: No