Skip to content

Commit

Permalink
Better console postprocessing for Node.js example
Browse files Browse the repository at this point in the history
  • Loading branch information
lydell committed Jan 6, 2025
1 parent 16cd126 commit 40b05ea
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions example/postprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export default async function postprocess({
*/
function patch(targetName, code) {
if (targetName === "Node.js") {
// Disable Elm’s “Compiled in DEV mode” logs.
return code.replace(/^console\.warn\('Compiled in DEV mode\..+'\);$/m, "");
return `(function(){const console = { warn() {/* Skip Elm's "Compiled in DEV mode" logs. */}, log: globalThis.console.warn /* Debug.log to stderr instead of stdout. */ }; ${code}}).call(this);`;
} else if (targetName.includes("ESM")) {
// Turn the Elm JS into an ECMAScript module:
return `const output = {}; (function(){${code}}).call(output); export default output.Elm;`;
Expand Down

0 comments on commit 40b05ea

Please sign in to comment.