diff --git a/README.md b/README.md index 1feb826..5c4b14d 100644 --- a/README.md +++ b/README.md @@ -60,17 +60,6 @@ import json from 'file.json'; import json from 'json-loader!file.json'; ``` - - -### Options - -#### `stringify` - -By default, the json-loader will output the json object, set this query parameter to 'true' can output the json object as a string, e.g. `require('json-loader?stringify!../index.json')`. - - - -

Maintainer

@@ -109,7 +98,6 @@ By default, the json-loader will output the json object, set this query paramete
- [npm]: https://img.shields.io/npm/v/json-loader.svg [npm-url]: https://npmjs.com/package/json-loader diff --git a/index.js b/index.js index 76b50dd..fc44d0d 100644 --- a/index.js +++ b/index.js @@ -1,16 +1,12 @@ /* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra */ -var loaderUtils = require('loader-utils'); - module.exports = function(source) { - var value = typeof source === "string" ? JSON.parse(source) : source; - var options = loaderUtils.getOptions(this) || {}; - value = JSON.stringify(value) - .replace(/\u2028/g, '\\u2028') - .replace(/\u2029/g, '\\u2029'); - value = options.stringify ? `'${value}'` : value - var module = this.version && this.version >= 2 ? `export default ${value};` : `module.exports = ${value};`; - return module + var value = typeof source === "string" ? JSON.parse(source) : source; + value = JSON.stringify(value) + .replace(/\u2028/g, '\\u2028') + .replace(/\u2029/g, '\\u2029'); + var module = this.version && this.version >= 2 ? `export default ${value};` : `module.exports = ${value};`; + return module; } diff --git a/package.json b/package.json index 75593f0..71422c5 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,5 @@ "repository": { "type": "git", "url": "https://github.com/webpack/json-loader.git" - }, - "dependencies": { - "loader-utils": "^1.0.3" } }