Skip to content

Commit 3902f14

Browse files
committed
ensure we don't add a newline for modules if we don't need it
1 parent d37a6b6 commit 3902f14

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/modules.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@
184184
// if we needed to load something, wait until it's loaded before resolving this
185185
Promise.all(newPromises).then(function(){
186186
// add the module to end of our array
187-
if (Espruino.Config.MODULE_AS_FUNCTION)
188-
loadedModuleData.push("Modules.addCached(" + JSON.stringify(module.name) + ",function(){" + module.code + "\n});");
187+
if (Espruino.Config.MODULE_AS_FUNCTION) // check for '//' is just in case, most minified modules shouldn't have it
188+
loadedModuleData.push("Modules.addCached(" + JSON.stringify(module.name) + ",function(){" + module.code.trim() + (module.code.includes("//")?"\n":"") + "});");
189189
else
190190
loadedModuleData.push("Modules.addCached(" + JSON.stringify(module.name) + "," + JSON.stringify(module.code) + ");");
191191
// We're done

0 commit comments

Comments
 (0)