]> git.immae.eu Git - github/fretlink/purs-loader.git/commitdiff
Merge pull request #45 from ethul/topic/issue-41
authoreric <thul.eric@gmail.com>
Tue, 15 Mar 2016 00:40:54 +0000 (20:40 -0400)
committereric <thul.eric@gmail.com>
Tue, 15 Mar 2016 00:40:54 +0000 (20:40 -0400)
Escape path for require

docs/PursLoader/JsStringEscape.md [new file with mode: 0644]
package.json
src/PursLoader/JsStringEscape.js [new file with mode: 0644]
src/PursLoader/JsStringEscape.purs [new file with mode: 0644]
src/PursLoader/Loader.purs

diff --git a/docs/PursLoader/JsStringEscape.md b/docs/PursLoader/JsStringEscape.md
new file mode 100644 (file)
index 0000000..09f52aa
--- /dev/null
@@ -0,0 +1,9 @@
+## Module PursLoader.JsStringEscape
+
+#### `jsStringEscape`
+
+``` purescript
+jsStringEscape :: String -> String
+```
+
+
index 04fd68078bffd03bbad2d832a126e1b6486f3ce5..a5c031550e01b9752d32331644c568535e3c2e5f 100644 (file)
@@ -24,8 +24,7 @@
     "webpack": "^1.8.4"
   },
   "dependencies": {
-    "async": "^1.3.0",
-    "chalk": "^1.1.0",
-    "debug": "^2.2.0"
+    "debug": "^2.2.0",
+    "js-string-escape": "^1.0.1"
   }
 }
diff --git a/src/PursLoader/JsStringEscape.js b/src/PursLoader/JsStringEscape.js
new file mode 100644 (file)
index 0000000..ff0a1a6
--- /dev/null
@@ -0,0 +1,7 @@
+'use strict';
+
+// module PursLoader.JsStringEscape
+
+var jsStringEscape = require('js-string-escape');
+
+exports.jsStringEscape = jsStringEscape;
diff --git a/src/PursLoader/JsStringEscape.purs b/src/PursLoader/JsStringEscape.purs
new file mode 100644 (file)
index 0000000..79590ae
--- /dev/null
@@ -0,0 +1,3 @@
+module PursLoader.JsStringEscape (jsStringEscape) where
+
+foreign import jsStringEscape :: String -> String
index 97954f67da7ba3e05cbea92abca2a7c35b4a7874..acb0993d6ada38d97c199d0c74306e4ae2403a53 100644 (file)
@@ -21,6 +21,8 @@ import Data.String.Regex (Regex(), match, noFlags, regex)
 
 import Unsafe.Coerce (unsafeCoerce)
 
+import PursLoader.Debug (debug)
+import PursLoader.JsStringEscape (jsStringEscape)
 import PursLoader.LoaderRef
   ( AsyncCallback()
   , LoaderRef()
@@ -30,8 +32,6 @@ import PursLoader.LoaderRef
   , addDependency
   , resourcePath
   )
-
-import PursLoader.Debug (debug)
 import PursLoader.Path (dirname, joinPath, relative)
 import PursLoader.Plugin as Plugin
 
@@ -79,13 +79,13 @@ loader ref source = do
          else moduleExport <<< modulePath <$> name
       where
       bundleExport :: String -> String
-      bundleExport name' = "module.exports = require('" ++ path ++ "')['" ++ name' ++ "'];"
+      bundleExport name' = "module.exports = require('" ++ jsStringEscape path ++ "')['" ++ name' ++ "'];"
         where
         path :: String
         path = relative resourceDir pluginContext.options.bundleOutput
 
       moduleExport :: String -> String
-      moduleExport path = "module.exports = require('" ++ path ++ "');"
+      moduleExport path = "module.exports = require('" ++ jsStringEscape path ++ "');"
 
       modulePath :: String -> String
       modulePath = relative resourceDir <<< joinPath pluginContext.options.output