I wasted some time debugging a strange issue, and finally realized that the Gren compiler changes the javascript application based on whether the output file has a ".js" extension or not.
E.g., I compiled the "cat" project in the example-projects, repo, like this:
gren make --output=app.js Main
node app.js
It compiled, but nothing happened when I ran it.
Then I compiled it without the .js extension:
gren make --output=app Main
node app
And it worked as expected.
A diff of app to app.js shows:
--- app 2026-03-27 07:42:57.157644252 -0500
+++ app.js 2026-03-27 07:42:16.131507826 -0500
@@ -1,6 +1,3 @@
-#!/usr/bin/env node
-
-try {
(function(scope){
'use strict';
@@ -4458,10 +4455,4 @@
};
var $gren_lang$core$Json$Decode$succeed = _Json_succeed;
var $author$project$Main$main = $gren_lang$node$Node$defineSimpleProgram($author$project$Main$init);
-_Platform_export({'Main':{'init':$author$project$Main$main($gren_lang$core$Json$Decode$succeed({ }))}});}(this.module ? this.module.exports : this));
-this.Gren.Main.init({});
-}
-catch (e)
-{
-console.error(e);
-}
+_Platform_export({'Main':{'init':$author$project$Main$main($gren_lang$core$Json$Decode$succeed({ }))}});}(this.module ? this.module.exports : this));
But also, I wonder, is this behavior necessary, considering that the project has been declared to be platform=node and type=application?
I wasted some time debugging a strange issue, and finally realized that the Gren compiler changes the javascript application based on whether the output file has a ".js" extension or not.
E.g., I compiled the "cat" project in the example-projects, repo, like this:
It compiled, but nothing happened when I ran it.
Then I compiled it without the .js extension:
And it worked as expected.
A diff of app to app.js shows:
But also, I wonder, is this behavior necessary, considering that the project has been declared to be platform=node and type=application?