Skip to content

Commit

Permalink
Merge branch 'master' into fix-nuxt-moment-usecase
Browse files Browse the repository at this point in the history
  • Loading branch information
iamakulov authored Nov 18, 2019
2 parents ae22ba6 + 388632b commit 2e1f6c9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function MomentLocalesPlugin(options) {

return new ContextReplacementPlugin(
/moment[\/\\]locale/,
new RegExp('(' + regExpPatterns.join('|') + ')$')
new RegExp('[/\\\\](' + regExpPatterns.join('|') + ')$')
);
} else {
return new IgnorePlugin(/^\.\/locale$/, /moment$/);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moment-locales-webpack-plugin",
"version": "1.1.1-0",
"version": "1.1.1",
"description": "Strip unused locales from Moment.js",
"main": "index.js",
"scripts": {
Expand Down
18 changes: 18 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,24 @@ describe('webpack build', () => {
expect(localeModules).toHaveLength(1);
expect(localeModules[0]).toMatch('moment/locale/en-gb');
});

// Covers https://github.com/iamakulov/moment-locales-webpack-plugin/issues/13
test('doesn’t include locales whose names intersect with a passed locale', async () => {
const modulePaths = await runWithWebpack({
localesToKeep: ['ca'],
});

const momentModule = modulePaths.find(path =>
path.includes('moment/moment.js')
);
expect(momentModule).toBeTruthy();

const localeModules = modulePaths.filter(path =>
path.includes(`moment/locale`)
);
expect(localeModules).toHaveLength(1);
expect(localeModules[0]).toMatch('moment/locale/ca');
});
});

describe('validation', () => {
Expand Down

0 comments on commit 2e1f6c9

Please sign in to comment.