codebox / moment-precise-range

A moment.js plugin to display human-readable date/time ranges
https://codebox.net/pages/moment-date-range-plugin
MIT License
150 stars 91 forks source link

Fix Webpack's misused require function error #23

Closed andfaulkner closed 7 years ago

andfaulkner commented 7 years ago

A Webpack error is produced when attempting to build any project that requires or imports the moment-precise-range plugin:

WARNING in ./~/moment-precise-range-plugin/moment-precise-range.js
Critical dependencies:
1:37-44 require function is used in a way in which dependencies cannot be statically extracted
@ ./~/moment-precise-range-plugin/moment-precise-range.js 1:37-44

The issue goes away if you make this change; while still retaining the original purpose of checking for require (i.e. to ensure require can be called).

codebox commented 7 years ago

@andfaulkner thanks for the fix