From 09e09fb310cf98cfd9581425b6a75b013f7be74e Mon Sep 17 00:00:00 2001 From: eric thul Date: Sat, 25 Feb 2017 10:09:45 -0500 Subject: [PATCH] Adding an additional module check --- src/to-javascript.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/to-javascript.js b/src/to-javascript.js index 0acf180..b402ad4 100644 --- a/src/to-javascript.js +++ b/src/to-javascript.js @@ -103,10 +103,19 @@ function makeJS(psModule, psModuleMap, js) { } const additionalImportsResult = additionalImports.map(import_ => { - const escapedPath = jsStringEscape(psModuleMap[import_].src); + const moduleValue = psModuleMap[import_]; - return `var ${import_.replace(/\./g, '_')} = require("${escapedPath}")`; - }).join('\n'); + if (!moduleValue) { + debug('module %s was not found in the map, skipping require', import_); + + return null; + } + else { + const escapedPath = jsStringEscape(moduleValue.src); + + return `var ${import_.replace(/\./g, '_')} = require("${escapedPath}")`; + } + }).filter(a => a !== null).join('\n'); const result_ = result + (additionalImports.length ? '\n' + additionalImportsResult : ''); -- 2.41.0