Topic: Is mdb.js meant to be imported?

bgoodfl pro asked 5 years ago


Expected behavior mdb.js should not have duplicate function names

Actual behavior mdb.js has duplicate function names which causes an error when importing. _classCallCheck, _defineProperties and _createClass are defined on lines 16728 - 16732 but duplicated on lines 17934 - 17938

Resources (screenshots, code snippets etc.) mdb in webpack entry point


bgoodfl pro answered 5 years ago


Here is the snippet https://mdbootstrp.com/snippets/jquery/bgoodfl/640592

But as I said, you just have to look at your source code to see that you cannot have 4 functions named the same.

I tried to attach screenshot to actually show the duplicate functions but all I get is an error when trying to upload.

All you have to do is create a snippet. Then just look at your compiled js file and search for function _createClass OR function _defineProperties or function _classCallCheck and you will see there are 4 of each.

In Javascript, this is not necessarily a huge issue because they are exact duplicates and the last function will replace the one before it. it becomes a bigger issue if their signatures are different. Javascript example below. BUT in the case of using it on the server with Babel and Webpack, it will not compile at all. I can't really share my project and could take the them to create an entire generic project using webpack and babel to show you but if should be pretty obvious to any developer just by looking at the code.

function _defineProperties() { this.getName = function() { return 'Property Name'; }; };

function _defineProperties() { };

var prop = new _defineProperties(); prop.name = prop.getName()); // Errror. There is no method called .getName because the second _defineProperties has wiped out the first.


Bartłomiej Malanowski staff commented 5 years ago

Thank you for the detailed answer. It's already on our bug list so this will be fixed soon


bgoodfl pro answered 5 years ago


To add more context, following the simple tutorial here https://mdbootstrap.com/education/bootstrap/quick-start/ and including a script reference to mdb.min.js would also include duplicate javascript functions.


Bartłomiej Malanowski staff commented 5 years ago

How can we reproduce your issue?


bgoodfl pro commented 5 years ago

Not sure what you mean. Follow your tutorial as I mentioned. Also, just looking at the Javascript file, you'll see the duplicate functions.I also went ahead and compared those lines and they are exact duplicates. After deleting them, the code works.


Bartłomiej Malanowski staff commented 5 years ago

I went through the tutorial, but I can't see the issue that you're facing. Please create a snippet where the issue would be visible: https://mdbootstrap.com/snippets/



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: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.7.7
  • Device: na/
  • Browser: n/a
  • OS: n/a
  • Provided sample code: No
  • Provided link: No