Skip to content
This repository was archived by the owner on Aug 20, 2018. It is now read-only.

Commit 6357639

Browse files
sokramichael-ciniawsky
authored andcommitted
revert: add stringify option to output JSON object as string (#43) (#52)
1 parent 62e9f34 commit 6357639

File tree

3 files changed

+8
-27
lines changed

3 files changed

+8
-27
lines changed

README.md

-12
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,6 @@ import json from 'file.json';
6060
import json from 'json-loader!file.json';
6161
```
6262

63-
64-
65-
### Options
66-
67-
#### `stringify`
68-
69-
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')`.
70-
71-
72-
73-
7463
<h2 align="center">Maintainer</h2>
7564

7665
<table>
@@ -109,7 +98,6 @@ By default, the json-loader will output the json object, set this query paramete
10998
<tbody>
11099
</table>
111100

112-
113101
[npm]: https://img.shields.io/npm/v/json-loader.svg
114102
[npm-url]: https://npmjs.com/package/json-loader
115103

index.js

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
/*
2-
MIT License http://www.opensource.org/licenses/mit-license.php
3-
Author Tobias Koppers @sokra
2+
MIT License http://www.opensource.org/licenses/mit-license.php
3+
Author Tobias Koppers @sokra
44
*/
5-
var loaderUtils = require('loader-utils');
6-
75
module.exports = function(source) {
8-
var value = typeof source === "string" ? JSON.parse(source) : source;
9-
var options = loaderUtils.getOptions(this) || {};
10-
value = JSON.stringify(value)
11-
.replace(/\u2028/g, '\\u2028')
12-
.replace(/\u2029/g, '\\u2029');
13-
value = options.stringify ? `'${value}'` : value
14-
var module = this.version && this.version >= 2 ? `export default ${value};` : `module.exports = ${value};`;
15-
return module
6+
var value = typeof source === "string" ? JSON.parse(source) : source;
7+
value = JSON.stringify(value)
8+
.replace(/\u2028/g, '\\u2028')
9+
.replace(/\u2029/g, '\\u2029');
10+
var module = this.version && this.version >= 2 ? `export default ${value};` : `module.exports = ${value};`;
11+
return module;
1612
}

package.json

-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@
77
"repository": {
88
"type": "git",
99
"url": "https://github.com/webpack/json-loader.git"
10-
},
11-
"dependencies": {
12-
"loader-utils": "^1.0.3"
1310
}
1411
}

0 commit comments

Comments
 (0)