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

Commit a191f43

Browse files
fix(index): only export CJS modules (webpack v1.0.0) && add deprecation warning (webpack v2.0.0)
1 parent 78aac1b commit a191f43

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

index.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
/*
2-
MIT License http://www.opensource.org/licenses/mit-license.php
3-
Author Tobias Koppers @sokra
4-
*/
5-
module.exports = function(source) {
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;
1+
module.exports = function (source) {
2+
if (this.cacheable) this.cacheable();
3+
4+
var value = typeof source === "string" ? JSON.parse(source) : source;
5+
6+
value = JSON.stringify(value)
7+
.replace(/\u2028/g, '\\u2028')
8+
.replace(/\u2029/g, '\\u2029');
9+
10+
if (this.version && this.version >= 2) {
11+
this.emitWarning(`⚠️ JSON Loader \n\nIt seems you're using webpack >= v2.0.0, which includes native support for JSON. Please remove this loader from webpack.config.js as it isn't needed anymore and is deprecated\n`)
12+
}
13+
14+
return `module.exports = ${value}`;
1215
}

0 commit comments

Comments
 (0)