I played with Elm a couple of times, and I wanted to make the Moment.JS port, as I saw the lack of libraries in what I wanted, but Moment has everything I need.
The fact is that I always encounter the same error. I have Moment.JS in my Native folder (it's called MomentJS.js) and another Moment.js file (my cover). The problem is that when I call the moment in Moment.js, I get an error message indicating that the moment is not defined.
I tried to import MomentJS.js into an elm file, as well as before and / or after Moment.js. I also tried copying all the JS into Moment.js and adding my wrapper at the end of it. None of this happened. Do you know what I can do? I searched for similar repositories on the Internet, but I never saw a module with a shell and another JS file only for the native library.
This is my Moment.js code:
var _user$project$Native_Moment = (function() { var moment = require('moment'); var format = function ( format, date ) { return moment().format(); } return { format: format }; })();
and my Moment.elm code:
module Moment exposing (format) {-| A module desc @docs format -} import Native.MomentJS import Native.Moment {-| Call the default `Moment.js` format method -} format : String -> String -> String format fm dt = Native.Moment.format fm dt
The last thing I tried was to download Moment from npm, copy its folder from the node_modules folder to my Native folder and do moment = require('moment') , but I got TypeError: fun(...) is not a function .
Any suggestions?
source share