Open dshastry opened 5 years ago
Is there any resource on how to develop a proper module, especially a moment
plugin? This plugin was developed by @kalmecak a while ago i think, back then there weren't well defined formats I think. On a personal level I would be quite interested in this specification
You can just add a shim to your requirejs config. This solution assumes you already have momentjs added as an AMD module. If you don't you'll need to add a path for it to your requirejs config.
config = {
paths: {
"moment-business-days": "path/to/moment-business-days/index"
},
// Add moment-business-days methods to moment.js (https://github.com/kalmecak/moment-business-days)
shim: {
"moment-business-days": ['moment']
}
}
Thanks for writing a great plugin that's been super helpful so far. One issue I just ran into is that the plugin does not work when used in a require JS / AMD environment. Below is the require block in require_config:
define('moment',['moment/2.24.0/moment.min', 'moment/plugins/business-days/plugin'],function (moment) { window.moment = moment; return moment; });
I get a moment is not defined error. If I throw in a require call or a timer that waits for the moment variable in the plugin file it all works. Would it be possible to add amd support to the code?