"cross-spawn": "^3.0.1",
"debug": "^2.2.0",
"globby": "^4.0.0",
+ "js-string-escape": "^1.0.1",
"loader-utils": "^0.2.14",
"promise-retry": "^1.1.0"
},
const spawn = require('cross-spawn')
const path = require('path')
const retryPromise = require('promise-retry')
+const jsStringEscape = require('js-string-escape')
const ffiModuleRegex = /\/\/\s+module\s+([\w\.]+)/i
const srcModuleRegex = /(?:^|\n)module\s+([\w\.]+)/i
if (options.bundle) {
// if bundling, return a reference to the bundle
js = 'module.exports = require("'
- + path.relative(psModule.srcDir, options.bundleOutput)
+ + jsStringEscape(path.relative(psModule.srcDir, options.bundleOutput))
+ '")["' + psModule.name + '"]'
} else {
// replace require paths to output files generated by psc with paths
// to purescript sources, which are then also run through this loader.
js = result.js
.replace(requireRegex, (m, p1) => {
- return 'require("' + result.psModuleMap[p1].src + '")'
+ return 'require("' + jsStringEscape(result.psModuleMap[p1].src) + '")'
})
.replace(/require\(['"]\.\/foreign['"]\)/g, (m, p1) => {
- return 'require("' + result.psModuleMap[psModule.name].ffi + '")'
+ return 'require("' + jsStringEscape(result.psModuleMap[psModule.name].ffi) + '")'
})
}