diff options
Diffstat (limited to 'src/PursLoader')
-rw-r--r-- | src/PursLoader/JsStringEscape.js | 7 | ||||
-rw-r--r-- | src/PursLoader/JsStringEscape.purs | 3 | ||||
-rw-r--r-- | src/PursLoader/Loader.purs | 8 |
3 files changed, 14 insertions, 4 deletions
diff --git a/src/PursLoader/JsStringEscape.js b/src/PursLoader/JsStringEscape.js new file mode 100644 index 0000000..ff0a1a6 --- /dev/null +++ b/src/PursLoader/JsStringEscape.js | |||
@@ -0,0 +1,7 @@ | |||
1 | 'use strict'; | ||
2 | |||
3 | // module PursLoader.JsStringEscape | ||
4 | |||
5 | var jsStringEscape = require('js-string-escape'); | ||
6 | |||
7 | exports.jsStringEscape = jsStringEscape; | ||
diff --git a/src/PursLoader/JsStringEscape.purs b/src/PursLoader/JsStringEscape.purs new file mode 100644 index 0000000..79590ae --- /dev/null +++ b/src/PursLoader/JsStringEscape.purs | |||
@@ -0,0 +1,3 @@ | |||
1 | module PursLoader.JsStringEscape (jsStringEscape) where | ||
2 | |||
3 | foreign import jsStringEscape :: String -> String | ||
diff --git a/src/PursLoader/Loader.purs b/src/PursLoader/Loader.purs index 97954f6..acb0993 100644 --- a/src/PursLoader/Loader.purs +++ b/src/PursLoader/Loader.purs | |||
@@ -21,6 +21,8 @@ import Data.String.Regex (Regex(), match, noFlags, regex) | |||
21 | 21 | ||
22 | import Unsafe.Coerce (unsafeCoerce) | 22 | import Unsafe.Coerce (unsafeCoerce) |
23 | 23 | ||
24 | import PursLoader.Debug (debug) | ||
25 | import PursLoader.JsStringEscape (jsStringEscape) | ||
24 | import PursLoader.LoaderRef | 26 | import PursLoader.LoaderRef |
25 | ( AsyncCallback() | 27 | ( AsyncCallback() |
26 | , LoaderRef() | 28 | , LoaderRef() |
@@ -30,8 +32,6 @@ import PursLoader.LoaderRef | |||
30 | , addDependency | 32 | , addDependency |
31 | , resourcePath | 33 | , resourcePath |
32 | ) | 34 | ) |
33 | |||
34 | import PursLoader.Debug (debug) | ||
35 | import PursLoader.Path (dirname, joinPath, relative) | 35 | import PursLoader.Path (dirname, joinPath, relative) |
36 | import PursLoader.Plugin as Plugin | 36 | import PursLoader.Plugin as Plugin |
37 | 37 | ||
@@ -79,13 +79,13 @@ loader ref source = do | |||
79 | else moduleExport <<< modulePath <$> name | 79 | else moduleExport <<< modulePath <$> name |
80 | where | 80 | where |
81 | bundleExport :: String -> String | 81 | bundleExport :: String -> String |
82 | bundleExport name' = "module.exports = require('" ++ path ++ "')['" ++ name' ++ "'];" | 82 | bundleExport name' = "module.exports = require('" ++ jsStringEscape path ++ "')['" ++ name' ++ "'];" |
83 | where | 83 | where |
84 | path :: String | 84 | path :: String |
85 | path = relative resourceDir pluginContext.options.bundleOutput | 85 | path = relative resourceDir pluginContext.options.bundleOutput |
86 | 86 | ||
87 | moduleExport :: String -> String | 87 | moduleExport :: String -> String |
88 | moduleExport path = "module.exports = require('" ++ path ++ "');" | 88 | moduleExport path = "module.exports = require('" ++ jsStringEscape path ++ "');" |
89 | 89 | ||
90 | modulePath :: String -> String | 90 | modulePath :: String -> String |
91 | modulePath = relative resourceDir <<< joinPath pluginContext.options.output | 91 | modulePath = relative resourceDir <<< joinPath pluginContext.options.output |