WebDevTmas / moment-round

Plugin for momentjs to round time in dates.
Other
47 stars 75 forks source link

Incompatible with r.js optimizer #6

Open jpuffer opened 8 years ago

jpuffer commented 8 years ago

Cannot be used with projects which productionize using Requirejs's built in optimizer. The following error in the optimized version:

require.js:1Uncaught Error: Module name "moment" has not been loaded yet for context: _. Use require([])
http://requirejs.org/docs/errors.html#notloaded
   makeError                @   require.js:1
   f                        @   require.js:1
   requirejs                @   require.js:1
   (anonymous function) @   moment-round.js:3
   (anonymous function) @   moment-round.js:55
WebDevTmas commented 8 years ago

I'm sorry but I'm really busy these weeks and have no time to get it fixed. But I believe the round method has been implemented natively in momentjs now?

jpuffer commented 8 years ago

Nope, Moment still references your plugin in the official docs http://momentjs.com/docs/#/plugins/round/ Not a big deal though, I just made a copy of the plugin and changed the first two lines to define(function(require) { 'use strict'; var moment = require("moment"); and deleted .call(this); from the end.

That fixed it for me. I would PR but I'm guessing this ruins the whole thing for regular non-module use.