Hi, I would like to use the moment-timezone library in my app (https://momentjs.com/downloads/moment-timezone-with-data-2012-2022.js). The problem is that it depends on moment.js. However, I don’t know how to expose moment.js in such a way that moment-timezone will be able to import it.
var moment = require('/js/moment.js');
var moment_tz = require('/js/moment-timezone.js');
I hoped that the first require would be enough to make this work. Unfortunately I still get this error:
Error: : Error message: Uncaught require(): module not found: moment
File name: js/moment-timezone.js
Line number: 14
Source line: module.exports = factory(require('moment')); // Node
Is there a way to do this?
Perhaps all you need to do is ensure that the JS files in question are included in the app bundle.
.unoproj file should have something like this in
Thank you for the suggestion @Uldis. I tried it, but no joy, it still doesn’t work. I had
**.js in there before but I tried putting exactly your string in just to be certain. I’ve also upgraded to the latest version of Fuse (1.3.0 14520) and the same problem persists… Perhaps you can try it on your end and see if it works on not…
Tested a little, and it seems I got it working alright. My assumption currently is that you need to get the paths right, since inside Fuse the
require() statement is relative to the project root.
So, if you changed that one line in question in
moment-timezone.js to this:
module.exports = factory(require('js/moment'));
it might just work.
Let me know if this helps!
Ah I see - that does work, thank you! I decided to keep moment.js and moment-timezone.js in my root directory because I didn’t want to have to change the source code for moment-timezone.js. Hopefully in some future release it may be possible for module imports to work without having to modify the source code for external libraries.