diff --git a/src/main/scala/io/shiftleft/js2cpg/preprocessing/BabelTranspiler.scala b/src/main/scala/io/shiftleft/js2cpg/preprocessing/BabelTranspiler.scala index ef2a1bca..274bcf0f 100644 --- a/src/main/scala/io/shiftleft/js2cpg/preprocessing/BabelTranspiler.scala +++ b/src/main/scala/io/shiftleft/js2cpg/preprocessing/BabelTranspiler.scala @@ -48,7 +48,7 @@ class BabelTranspiler( "--source-maps true " + babelPresets + babelPlugins + s"--out-dir '$outDir' $constructIgnoreDirArgs" logger.debug(s"\t+ Babel transpiling '$projectPath' to '$outDir' with command '$command'") - ExternalCommand.run(command, in.toString) match { + ExternalCommand.run(command, in.toString, extraEnv = NODE_OPTIONS) match { case Success(_) => logger.debug("\t+ Babel transpiling finished") case Failure(exception) => logger.debug("\t- Babel transpiling failed", exception) } diff --git a/src/main/scala/io/shiftleft/js2cpg/preprocessing/Transpiler.scala b/src/main/scala/io/shiftleft/js2cpg/preprocessing/Transpiler.scala index 9cf7462e..763ab31b 100644 --- a/src/main/scala/io/shiftleft/js2cpg/preprocessing/Transpiler.scala +++ b/src/main/scala/io/shiftleft/js2cpg/preprocessing/Transpiler.scala @@ -6,6 +6,8 @@ import java.nio.file.Path trait Transpiler extends TranspilingEnvironment { + protected val NODE_OPTIONS: Map[String, String] = Map("NODE_OPTIONS" -> "--max-old-space-size=8192") + protected val DEFAULT_IGNORED_DIRS: List[String] = List( "build", "dist", diff --git a/src/main/scala/io/shiftleft/js2cpg/preprocessing/TranspilerGroup.scala b/src/main/scala/io/shiftleft/js2cpg/preprocessing/TranspilerGroup.scala index f1784100..d72266b5 100644 --- a/src/main/scala/io/shiftleft/js2cpg/preprocessing/TranspilerGroup.scala +++ b/src/main/scala/io/shiftleft/js2cpg/preprocessing/TranspilerGroup.scala @@ -25,7 +25,7 @@ case class TranspilerGroup(override val config: Config, override val projectPath } logger.info("Installing project dependencies and plugins. That will take a while.") logger.debug(s"\t+ Installing plugins with command '$command' in path '$projectPath'") - ExternalCommand.run(command, projectPath.toString) match { + ExternalCommand.run(command, projectPath.toString, extraEnv = NODE_OPTIONS) match { case Success(_) => logger.info("\t+ Plugins installed") true diff --git a/src/main/scala/io/shiftleft/js2cpg/preprocessing/TranspilingEnvironment.scala b/src/main/scala/io/shiftleft/js2cpg/preprocessing/TranspilingEnvironment.scala index c6e235e9..92f670bd 100644 --- a/src/main/scala/io/shiftleft/js2cpg/preprocessing/TranspilingEnvironment.scala +++ b/src/main/scala/io/shiftleft/js2cpg/preprocessing/TranspilingEnvironment.scala @@ -127,6 +127,7 @@ trait TranspilingEnvironment { case None => nodeVersion() isValid = Some(pnpmAvailable(dir) || yarnAvailable() || npmAvailable()) + logger.debug(s"\t+ additional node ENV settings: '${NODE_OPTIONS.mkString}'") isValid.get } diff --git a/src/main/scala/io/shiftleft/js2cpg/preprocessing/TypescriptTranspiler.scala b/src/main/scala/io/shiftleft/js2cpg/preprocessing/TypescriptTranspiler.scala index cafb1ed7..1e41f3fc 100644 --- a/src/main/scala/io/shiftleft/js2cpg/preprocessing/TypescriptTranspiler.scala +++ b/src/main/scala/io/shiftleft/js2cpg/preprocessing/TypescriptTranspiler.scala @@ -33,8 +33,6 @@ class TypescriptTranspiler(override val config: Config, override val projectPath private val logger = LoggerFactory.getLogger(getClass) - private val NODE_OPTIONS: Map[String, String] = Map("NODE_OPTIONS" -> "--max_old_space_size=4096") - private val tsc = Paths.get(projectPath.toString, "node_modules", ".bin", "tsc").toString private val typescriptAndVersion = Versions.nameAndVersion("typescript") diff --git a/src/main/scala/io/shiftleft/js2cpg/preprocessing/VueTranspiler.scala b/src/main/scala/io/shiftleft/js2cpg/preprocessing/VueTranspiler.scala index 082922bc..b034fe3c 100644 --- a/src/main/scala/io/shiftleft/js2cpg/preprocessing/VueTranspiler.scala +++ b/src/main/scala/io/shiftleft/js2cpg/preprocessing/VueTranspiler.scala @@ -32,7 +32,7 @@ class VueTranspiler(override val config: Config, override val projectPath: Path) private val logger = LoggerFactory.getLogger(getClass) - private lazy val NODE_OPTIONS: Map[String, String] = nodeOptions() + private lazy val VUE_NODE_OPTIONS: Map[String, String] = nodeOptions() private val vue = Paths.get(projectPath.toString, "node_modules", ".bin", "vue-cli-service").toString private val vueAndVersion = Versions.nameAndVersion("@vue/cli-service-global") @@ -62,7 +62,7 @@ class VueTranspiler(override val config: Config, override val projectPath: Path) } logger.info("Installing Vue.js dependencies and plugins. That will take a while.") logger.debug(s"\t+ Installing Vue.js plugins with command '$command' in path '$projectPath'") - ExternalCommand.run(command, projectPath.toString, extraEnv = NODE_OPTIONS) match { + ExternalCommand.run(command, projectPath.toString, extraEnv = VUE_NODE_OPTIONS) match { case Success(_) => logger.info("\t+ Vue.js plugins installed") true @@ -88,7 +88,7 @@ class VueTranspiler(override val config: Config, override val projectPath: Path) createCustomBrowserslistFile() val command = s"${ExternalCommand.toOSCommand(vue)} build --dest '$tmpTranspileDir' --mode development --no-clean" logger.debug(s"\t+ Vue.js transpiling $projectPath to '$tmpTranspileDir'") - ExternalCommand.run(command, projectPath.toString, extraEnv = NODE_OPTIONS) match { + ExternalCommand.run(command, projectPath.toString, extraEnv = VUE_NODE_OPTIONS) match { case Success(_) => logger.debug("\t+ Vue.js transpiling finished") case Failure(exception) => logger.debug("\t- Vue.js transpiling failed", exception) }