From 30701651507e6956988c60a4ed236550a2755d9e Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 8 May 2017 00:35:09 +0200 Subject: [PATCH 1/3] Revert "docs(README): add warning about webpack 2 usage (#49)" This reverts commit 62e9f3499b9e11654e2ae66d7daead4b7ab70bea. From 65a2e506e8130cdb79beabd5299f23784afc9126 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 8 May 2017 00:35:09 +0200 Subject: [PATCH 2/3] Revert "fix: escape newline/paragraph separators (#18)" This reverts commit 3b3069fa3f9deb35cc625c6c388e234a240ee312. From 0874a9c946942dd378446e24305509ea72acad46 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 8 May 2017 00:35:09 +0200 Subject: [PATCH 3/3] Revert "fix: add `stringify` option to output JSON object as string (#45)" This reverts commit 84681978038ed8ef516fe008406599e5ecb76ec7. --- README.md | 12 ------------ index.js | 16 ++++++---------- package.json | 3 --- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 7a0436a..99bd3b4 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 5cadd7d..bb7b2c0 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,10 @@ /* - 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) - value = options.stringify ? `'${value}'` : value - var module = this.version && this.version >= 2 ? `export default ${value};` : `module.exports = ${value};`; - return module + this.cacheable && this.cacheable(); + var value = typeof source === "string" ? JSON.parse(source) : source; + this.value = [value]; + return "module.exports = " + JSON.stringify(value) + ";"; } 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" } }