This repository has been archived by the owner on Aug 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(index): only export CJS modules (
webpack v1.0.0
) && add depreca…
…tion warning (`webpack v2.0.0`) (#55)
- Loading branch information
1 parent
78aac1b
commit d34395a
Showing
1 changed file
with
18 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
/* | ||
MIT License http://www.opensource.org/licenses/mit-license.php | ||
Author Tobias Koppers @sokra | ||
*/ | ||
module.exports = function(source) { | ||
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; | ||
module.exports = function (source) { | ||
if (this.cacheable) this.cacheable(); | ||
|
||
var value = typeof source === "string" ? JSON.parse(source) : source; | ||
|
||
value = JSON.stringify(value) | ||
.replace(/\u2028/g, '\\u2028') | ||
.replace(/\u2029/g, '\\u2029'); | ||
|
||
if (this.version && this.version >= 2) { | ||
this.emitWarning(`⚠️ JSON Loader\n | ||
It 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. See the v1.0.0 -> v2.0.0 migration guide for more information | ||
(https://webpack.js.org/guides/migrating/#json-loader-is-not-required-anymore)\n`) | ||
} | ||
|
||
return `module.exports = ${value}`; | ||
} |