From ecc956f8a2670c4861c94be43436f139cac1073d Mon Sep 17 00:00:00 2001 From: Rasmus Andersson Date: Thu, 15 Oct 2020 13:38:49 -0700 Subject: [PATCH] updates wasmc config to enable several emcc debug features in debug mode and updated build product config --- wasmc.js | 54 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/wasmc.js b/wasmc.js index 8cced2a..c92392b 100644 --- a/wasmc.js +++ b/wasmc.js @@ -2,8 +2,6 @@ const package = require("./package.json") const outdir = debug ? builddir : "dist" const m = { - name: "markdown", - out: outdir + "/markdown.js", jsentry: "src/md.js", sources: [ "src/wlib.c", @@ -13,31 +11,49 @@ const m = { "src/fmt_html.c", // "src/fmt_json.c", ], - cflags: debug ? ["-DDEBUG=1"] : [], + cflags: [ + "-DMD4C_USE_UTF8", + ].concat(debug ? [ + // debug flags + "-DDEBUG=1", + "-DASSERTIONS=1", // emcc + "-DSAFE_HEAP=1", // emcc + "-DSTACK_OVERFLOW_CHECK=1", // emcc + "-DDEMANGLE_SUPPORT=1", // emcc + ] : [ + // release flags + ]), constants: { VERSION: package.version, }, } +// ————————————————————————————————————————————————— +// products + +// embedded wasm, ES module, nodejs-specific compression +// Suitable for using or bundling as a library targeting nodejs only +module({ ...m, + name: "markdown-node", + out: outdir + "/markdown.node.js", + target: "node", + embed: true, +}) if (!debug) { - // generic js module - module({...m}) + // sideloaded wasm, universal js library, exports API at global["markdown"] as a fallback + // Suitable as a runtime library in browsers + module({ ...m, + name: "markdown", + out: outdir + "/markdown.js", + }) - // node cjs module + // embedded wasm, ES module + // Suitable for bundling as a library intended for browsers module({ ...m, - name: "markdown-node", - out: outdir + "/markdown.node.js", - target: "node", - embed: true, + name: "markdown-es", + out: outdir + "/markdown.es.js", + outwasm: outdir + "/markdown.wasm", + format: "es", }) } - -// node es module -module({ ...m, - name: "markdown-es", - out: outdir + "/markdown.es.js", - format: "es", - target: "node", - embed: true, -})