logbon72 / angular-material-datetimepicker

Datepicker for Angular Material, mimick's Android's date time picker
https://logbon72.github.io/angular-material-datetimepicker
MIT License
169 stars 123 forks source link

Webpack compatibility #110

Open ptitdam2001 opened 7 years ago

ptitdam2001 commented 7 years ago

Hi! It will be fun if the module is compatible with RequireJS/Webpack

hexadecy commented 7 years ago

Is this enough?

From PR #99

  var isElectron = window && window.process && window.process.type;
  if (typeof define === 'function' && define.amd) {
    define(['moment'], ngMaterialDatePicker);
  } else if (typeof module !== 'undefined' && module && module.exports && (typeof require === 'function') && !isElectron) {
    module.exports = ngMaterialDatePicker(require('moment'));
  } else {
    ngMaterialDatePicker((typeof global !== 'undefined' ? global : window).moment);
  }
ptitdam2001 commented 7 years ago

It looks like good!

hexadecy commented 7 years ago

Ok please test v1.6.6

ptitdam2001 commented 7 years ago

Hi,

I'm just testing 1.6.6 version using webpack. It is OK when you do a require('ng-material-datetimepicker'); but in general when you use require, it returns the name of module.

For example :

var ngMaterialDatetimepicker = require('ng-material-datetimepicker');

angular.module('mainModule', [ngMaterialDatetimepicker]);

It fails because your constructor return nothing. You should return the variable moduleName value at the end of function ngMaterialDatePicker(moment), it will resolve the issue

hexadecy commented 7 years ago

@ptitdam2001 is this ok?