From eb669658c133a06345d8dbbbe303a9fd172e10c7 Mon Sep 17 00:00:00 2001 From: Benedikt Meurer Date: Wed, 27 Sep 2017 22:07:36 +0200 Subject: [PATCH] fix: escape newline/paragraph separators Similar to https://github.com/webpack-contrib/json-loader/pull/18 the `raw-loader` also needs to properly escape the special unicode characters, as otherwise `webpack` get's highly confused when it sees one of them. --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a59e712..3db1fa4 100644 --- a/index.js +++ b/index.js @@ -5,5 +5,8 @@ module.exports = function(content) { this.cacheable && this.cacheable(); this.value = content; - return "module.exports = " + JSON.stringify(content); + content = JSON.stringify(content) + .replace(/\u2028/g, '\\u2028') + .replace(/\u2029/g, '\\u2029'); + return `module.exports = ${content}`; }