I’m trying to add Tempus Dominus datetimepicker into Sage 9 which requires moment.js as a dependency.
I have tried various combinations of imports into webpack and I can get it to compile properly but the page doesn’t load properly and the browser console logs: Uncaught Error: Tempus Dominus Bootstrap4's requires moment.js. Moment.js must be included before Tempus Dominus Bootstrap4's JavaScript.
I have tried various ordering in main.js and also tried to namespace and library.add(moment) but I am going nowhere.
Once you’ve done that, you don’t need to import moment in any of your other JS files; it will be available as needed.
Example home.js:
import "tempusdominus-bootstrap-4";
export default {
init() {
// JavaScript to be fired on the home page
$("#datetimepicker1").datetimepicker();
},
finalize() {
// JavaScript to be fired on the home page, after the init JS
},
};