Skip to content

Commit

Permalink
Compatibility with webpack. See kodie#19.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldenning committed Aug 7, 2019
1 parent e0ef221 commit 889b803
Show file tree
Hide file tree
Showing 10 changed files with 6,775 additions and 18 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
35 changes: 32 additions & 3 deletions build/moment-holiday-pkg.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/moment-holiday-pkg.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/moment-holiday-us.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/moment-holiday-us.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/moment-holiday.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/moment-holiday.min.js.map

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions moment-holiday.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
//! https://github.com/kodie/moment-holiday

(function() {
var moment = (typeof require !== 'undefined' && require !== null) && !require.amd ? require('moment') : this.moment;
// var moment = (typeof require !== 'undefined' && require !== null) && !require.amd ? require('moment') : this.moment;

// for web to work, we need to require moment without doing all the other checks:
var moment = require("moment");

var parserExtensions = [];

Expand Down Expand Up @@ -283,13 +286,16 @@
locale = regions[0].toLowerCase().replace(' ', '_');
regions.shift();

if (!moment.holidays[locale]) {
try {
var path = './locale/';
if (__dirname.split('/').slice(-1).pop() == 'build') { path = '.' + path; }
require(path + locale);
} catch(e) { }
}
// This code doesn't work with webpack, so it's commented out
// If you want locales, you should import them yourself separately

// if (!moment.holidays[locale]) {
// try {
// var path = './locale/';
// if (__dirname.split('/').slice(-1).pop() == 'build') { path = '.' + path; }
// require(path + locale);
// } catch(e) { }
// }

if (moment.holidays[locale]) {
if (regions.length) { return compileRegions(locale, regions); }
Expand Down
Loading

0 comments on commit 889b803

Please sign in to comment.