diff --git a/index.js b/index.js index 3db1fa4..5266dbb 100644 --- a/index.js +++ b/index.js @@ -2,11 +2,12 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ +const jsesc = require('jsesc'); + module.exports = function(content) { this.cacheable && this.cacheable(); this.value = content; - content = JSON.stringify(content) - .replace(/\u2028/g, '\\u2028') - .replace(/\u2029/g, '\\u2029'); - return `module.exports = ${content}`; + content = JSON.stringify(content); + content = jsesc(content); + return 'module.exports = ' + content; } diff --git a/package.json b/package.json index a27d997..0f35b7e 100644 --- a/package.json +++ b/package.json @@ -7,5 +7,8 @@ "type": "git", "url": "git@github.com:webpack/raw-loader.git" }, - "license": "MIT" + "license": "MIT", + "dependencies": { + "jsesc": "^2.5.1" + } }