tempusdominus / bootstrap-4

Tempus Dominus Bootstrap 4 Datetime Picker
https://getdatepicker.com/5-4/
MIT License
611 stars 239 forks source link

Tempus Dominus Bootstrap4's requires moment.js. Moment.js must be included before Tempus Dominus Bootstrap4's JavaScript angular js #295

Open RuchiJadon opened 4 years ago

RuchiJadon commented 4 years ago

I have been struggling with this error for long. Can anyone help me with this? I have all the dependencies installed. This is in AngularJs application. All prerequisites are already installed like - moment, jquery, tempusdominus-core, moment-timezone.

schugabe commented 4 years ago

If you are using webpack: you must register moment via ProvidePlugin to make it available.

tonix-tuft commented 4 years ago

@schugabe Could you provide an example? Thanks

schugabe commented 4 years ago

I use webpacker (with rails) and this is my config. I don't know how this would work without rails/webpacker.

const { environment } = require('@rails/webpacker');

const webpack = require('webpack');
environment.plugins.prepend('Provide',
  new webpack.ProvidePlugin({
    $: 'jquery',
    jQuery: 'jquery',
    moment: 'moment',
    Popper: 'popper.js'
  })
);

module.exports = environment;
tonix-tuft commented 4 years ago

Thank you!

Just to know, if I use webpack.ProvidePlugin, the deps will be provided to the code using it through window, but in the end e.g. jQuery or moment won't be set to the global window object in the final Webpack bundle, correct?