Skip to content
This repository was archived by the owner on Jan 3, 2019. It is now read-only.

Commit 6868b85

Browse files
eemelicletusw
authored andcommitted
Rewrite for WebPack loader API v2, updating dependencies (#2)
Rewrite for WebPack loader API v2, updating dependencies
1 parent fc8a7ca commit 6868b85

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

index.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,26 @@ var loaderUtils = require('loader-utils');
22
var MessageFormat = require('messageformat');
33

44
module.exports = function(content) {
5-
var query = loaderUtils.parseQuery(this.query);
6-
var locale = query.locale || 'en';
7-
var messages = (Array.isArray(this.inputValue) && typeof this.inputValue[0] === 'object') ? this.inputValue[0] : this.exec(content, this.resource);
5+
var options = loaderUtils.getOptions(this);
6+
var locale = options.locale;
7+
if (typeof locale === 'string' && locale.indexOf(',') !== -1) locale = locale.split(',');
8+
var messages = JSON.parse(content);
89
var messageFormat = new MessageFormat(locale);
9-
if (query.disablePluralKeyChecks) {
10+
if (options.disablePluralKeyChecks) {
1011
messageFormat.disablePluralKeyChecks();
1112
}
12-
if (query.intlSupport) {
13+
if (options.intlSupport) {
1314
messageFormat.setIntlSupport(true);
1415
}
16+
if (options.biDiSupport) {
17+
messageFormat.setBiDiSupport();
18+
}
19+
if (options.formatters) {
20+
messageFormat.addFormatters(options.formatters);
21+
}
22+
if (options.strictNumberSign) {
23+
messageFormat.setStrictNumberSign();
24+
}
1525
var messageFunctions = messageFormat.compile(messages);
1626

1727
this.cacheable && this.cacheable();

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
},
2929
"homepage": "https://github.com/cletusw/messageformat-loader#readme",
3030
"peerDependencies": {
31-
"messageformat": "^1.0.0-rc.3"
31+
"messageformat": "1.x"
3232
},
3333
"dependencies": {
34-
"loader-utils": "^0.2.15"
34+
"loader-utils": "^1.1.0"
3535
}
3636
}

0 commit comments

Comments
 (0)