described-i18n-loader
Advanced tools
Comparing version
@@ -6,2 +6,4 @@ /* | ||
const loaderUtils = require("loader-utils"); | ||
function descendIntoObject(target) { | ||
@@ -36,2 +38,3 @@ const output = {}; | ||
this.cacheable(true); | ||
const options = loaderUtils.getOptions(this) || {}; | ||
@@ -45,3 +48,3 @@ const locale = JSON.parse(str); | ||
const module = this.version && this.version >= 2 | ||
const module = this.version && this.version >= 2 && !options.forceModuleExports | ||
? `export default ${value};` | ||
@@ -48,0 +51,0 @@ : `module.exports = ${value};`; |
{ | ||
"name": "described-i18n-loader", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "Load i18n json files with key value pairs while stripping the 'desc' key from all subkeys. eg: key = 'conf.title', value = { text: \"Configuration\", desc: \"Title for config screen\" }", | ||
@@ -15,3 +15,4 @@ "main": "index.js", | ||
"webpack": "webpack", | ||
"test": "webpack test/index.js out/bundle.js" | ||
"test-node": "webpack test/node.js out/bundle-node.js", | ||
"test-es6": "webpack test/es6.js out/bundle-es6.js" | ||
}, | ||
@@ -22,3 +23,6 @@ "author": "erdii <erdiicodes@gmail.com>", | ||
"webpack": "^2.3.2" | ||
}, | ||
"dependencies": { | ||
"loader-utils": "^1.1.0" | ||
} | ||
} |
@@ -46,2 +46,3 @@ # described-18n-loader | ||
**(node)** | ||
```JSON | ||
@@ -56,1 +57,17 @@ module.exports = { | ||
``` | ||
**(es6)** | ||
```JSON | ||
export default { | ||
"conf.title": "Configuration", | ||
"app.title": "MyApp", | ||
"nav.button.home": "Home", | ||
"nav.button.about": "About", | ||
"another.pure.key": "Pure Key" | ||
} | ||
``` | ||
## Options | ||
* `forceModuleExports`: force node style module `DEFAULT - webpack 1: true, webpack 2: false` |
3039
22.39%39
5.41%72
30.91%1
Infinity%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added