paper-datatable-api icon indicating copy to clipboard operation
paper-datatable-api copied to clipboard

RangeDatepickerBehavior is not defined when bundling with Webpack

Open govis opened this issue 7 years ago • 1 comments

Ever since you introduced range-datepicker and moment dependency my Webpack-built project is getting an error:

ReferenceError: RangeDatepickerBehavior is not defined

It's coming from the RangeDatepickerInput class declaration:

class RangeDatepickerInput extends Polymer.mixinBehaviors(
  [Polymer.Templatizer],
  RangeDatepickerBehavior(Polymer.Element)
) {

It seems to me that RangeDatepickerBehavior is not available in the global context as it gets wrapped in a module by Webpack. Adding

window['RangeDatepickerBehavior'] = RangeDatepickerBehavior;
to range-datepicker-behavior.js solves the problem, but there might be more elegant solution, such as declaring a project-specific namespace for example.

Also just an FYI, moment seems to have some issues with Webpack as well:

WARNING in ./import/moment/min/moment-with-locales.min.js
Module not found: Error: Can't resolve './locale' in '...\import\moment\min'
 @ ./import/moment/min/moment-with-locales.min.js 1:8507-8529
 @ ./import/range-datepicker/moment-import.html
 @ ./import/range-datepicker/range-datepicker-input.html
 @ ./import/paper-datatable-api/paper-datatable-api-th-content.html
 @ ./import/paper-datatable-api/paper-datatable-api.html

Thanks

govis avatar Dec 01 '17 19:12 govis

Found the moment issue related to Webpack: https://github.com/moment/moment/issues/4218

govis avatar Dec 01 '17 20:12 govis