Description: The DEBUG variant has some issues with emscripten version in Debian
 and is pretty much useless, so it is excluded from the build output and tests.
Last-Update: 2023-08-07
Author: Israel Galadima <izzygaladima@gmail.com>
Forwarded: not-needed

--- a/ts/quickjs.test.ts
+++ b/ts/quickjs.test.ts
@@ -16,7 +16,7 @@
 import fs, { chmod } from "fs"
 import { QuickJSContext } from "./context"
 import { QuickJSAsyncContext } from "./context-asyncify"
-import { DEBUG_ASYNC, DEBUG_SYNC, memoizePromiseFactory, QuickJSFFI } from "./variants"
+import { memoizePromiseFactory, QuickJSFFI } from "./variants"
 import { QuickJSUnwrapError } from "./errors"
 import { debugLog } from "./debug"
 import { EitherFFI } from "./types"
@@ -1021,11 +1021,14 @@
     contextTests.call(this, getContext)
   })
 
+  /**
   describe("DEBUG sync module", function () {
     const loader = memoizePromiseFactory(() => newQuickJSWASMModule(DEBUG_SYNC))
     const getContext = () => loader().then((mod) => mod.newContext())
     contextTests.call(this, getContext, true)
   })
+  **/
+
 })
 
 if (!TEST_NO_ASYNC) {
@@ -1043,6 +1046,7 @@
       })
     })
 
+    /**
     describe("DEBUG async module", function () {
       const loader = memoizePromiseFactory(() => newQuickJSAsyncWASMModule(DEBUG_ASYNC))
       const getContext = () => loader().then((mod) => mod.newContext())
@@ -1055,6 +1059,8 @@
         asyncContextTests(getContext)
       })
     })
+    **/
+
   })
 }
 
--- a/ts/variants.test.ts
+++ b/ts/variants.test.ts
@@ -3,8 +3,6 @@
 import { QuickJSWASMModule } from "./module"
 import {
   AsyncBuildVariant,
-  DEBUG_ASYNC,
-  DEBUG_SYNC,
   RELEASE_ASYNC,
   RELEASE_SYNC,
   SyncBuildVariant,
@@ -42,6 +40,8 @@
       assert.deepStrictEqual(getModuleBuildInfo(await getQuickJS()), DEFAULT_VARIANT)
     })
   })
+
+  /**
   describe("DEBUG_SYNC", () => {
     it("has expected build settings", async () => {
       assert.deepStrictEqual(await getVariantBuildInfo(DEBUG_SYNC), {
@@ -52,6 +52,7 @@
       })
     })
   })
+  **/
 
   describe("RELEASE_SYNC", () => {
     it("has expected build settings", async () => {
@@ -59,6 +60,7 @@
     })
   })
 
+  /**
   describe("DEBUG_ASYNC", () => {
     it("has expected build settings", async () => {
       assert.deepStrictEqual(await getVariantBuildInfo(DEBUG_ASYNC), {
@@ -69,6 +71,7 @@
       })
     })
   })
+  **/
 
   describe("RELEASE_ASYNC", () => {
     it("has expected build settings", async () => {
--- a/ts/leak.test.ts
+++ b/ts/leak.test.ts
@@ -1,7 +1,7 @@
 import assert from "assert"
 import { getQuickJS, newQuickJSAsyncWASMModule, newQuickJSWASMModule } from "."
 import { QuickJSWASMModule } from "./module"
-import { DEBUG_ASYNC, DEBUG_SYNC, memoizePromiseFactory as memoizeNewModule } from "./variants"
+import { memoizePromiseFactory as memoizeNewModule } from "./variants"
 
 const TEST_LEAK = Boolean(process.env.TEST_LEAK)
 
@@ -151,19 +151,23 @@
 }
 
 describe("Leak checks (most accurate with debug build)", function () {
+  /**
   describe("DEBUG sync module", function () {
     const loader = memoizeNewModule(() => newQuickJSWASMModule(DEBUG_SYNC))
     checkModuleForLeaks.call(this, loader)
   })
+  **/
 
   describe("RELEASE sync module", function () {
     checkModuleForLeaks.call(this, getQuickJS)
   })
 
+  /**
   describe.skip("DEBUG async module", function () {
     const loader = memoizeNewModule(() => newQuickJSAsyncWASMModule(DEBUG_ASYNC))
     checkModuleForLeaks.call(this, loader)
   })
+  **/
 
   // Leaving this enabled, but note that we now disable
   // leak sanitizer for ASYNCIFY since it's not reliable.
--- a/ts/readme.test.ts
+++ b/ts/readme.test.ts
@@ -1,6 +1,5 @@
 import assert from "assert"
 import {
-  DEBUG_SYNC,
   getQuickJS,
   newAsyncContext,
   newQuickJSAsyncWASMModule,
@@ -291,10 +290,12 @@
     }
 
     // Run the test suite against a matrix of module loaders.
+    /**
     describe("Check for memory leaks with QuickJS DEBUG build", () => {
       const moduleLoader = memoizePromiseFactory(() => newQuickJSWASMModule(DEBUG_SYNC))
       myTests(moduleLoader)
     })
+    **/
 
     describe("Realistic test with QuickJS RELEASE build", () => {
       myTests(getQuickJS)
--- a/ts/variants.ts
+++ b/ts/variants.ts
@@ -1,6 +1,6 @@
-import type { QuickJSAsyncFFI as DebugAsyncifyFFI } from "./generated/ffi.WASM_DEBUG_ASYNCIFY"
+// import type { QuickJSAsyncFFI as DebugAsyncifyFFI } from "./generated/ffi.WASM_DEBUG_ASYNCIFY"
 import type { QuickJSAsyncFFI as ReleaseAsyncifyFFI } from "./generated/ffi.WASM_RELEASE_ASYNCIFY"
-import type { QuickJSFFI as DebugSyncFFI } from "./generated/ffi.WASM_DEBUG_SYNC"
+// import type { QuickJSFFI as DebugSyncFFI } from "./generated/ffi.WASM_DEBUG_SYNC"
 import type { QuickJSFFI as ReleaseSyncFFI } from "./generated/ffi.WASM_RELEASE_SYNC"
 import type {
   EmscriptenModuleLoader,
@@ -12,13 +12,13 @@
 import { unwrapTypescript, unwrapJavascript } from "./esmHelpers"
 
 /** @private */
-export type QuickJSFFI = DebugSyncFFI | ReleaseSyncFFI
+export type QuickJSFFI = ReleaseSyncFFI
 /** @private */
-export type QuickJSFFIConstructor = typeof DebugSyncFFI | typeof ReleaseSyncFFI
+export type QuickJSFFIConstructor = typeof ReleaseSyncFFI
 /** @private */
-export type QuickJSAsyncFFI = DebugAsyncifyFFI | ReleaseAsyncifyFFI
+export type QuickJSAsyncFFI = ReleaseAsyncifyFFI
 /** @private */
-export type QuickJSAsyncFFIConstructor = typeof DebugAsyncifyFFI | typeof ReleaseAsyncifyFFI
+export type QuickJSAsyncFFIConstructor = typeof ReleaseAsyncifyFFI
 
 /**
  * quickjs-emscripten provides multiple build variants of the core WebAssembly
@@ -30,7 +30,6 @@
  * Synchronous build variants:
  *
  * - {@link RELEASE_SYNC} - This is the default synchronous variant, for general purpose use.
- * - {@link DEBUG_SYNC} - Synchronous build variant for debugging memory leaks.
  */
 export interface SyncBuildVariant {
   type: "sync"
@@ -48,7 +47,6 @@
  * Asyncified build variants:
  *
  * - {@link RELEASE_ASYNC} - This is the default asyncified build variant, for general purpose use.
- * - {@link DEBUG_ASYNC} - Asyncified build variant with debug logging.
  */
 export interface AsyncBuildVariant {
   type: "async"
@@ -114,7 +112,7 @@
 /**
  * Helper intended to memoize the creation of a WebAssembly module.
  * ```typescript
- * const getDebugModule = memoizePromiseFactory(() => newQuickJSWASMModule(DEBUG_SYNC))
+ * const getDebugModule = memoizePromiseFactory(() => newQuickJSWASMModule())
  * ```
  */
 export function memoizePromiseFactory<T>(fn: () => Promise<T>): () => Promise<T> {
@@ -125,30 +123,6 @@
 }
 
 /**
- * This build variant is compiled with `-fsanitize=leak`. It instruments all
- * memory allocations and when combined with sourcemaps, can present stack trace
- * locations where memory leaks occur.
- *
- * See [[TestQuickJSWASMModule]] which provides access to the leak sanitizer via
- * {@link TestQuickJSWASMModule.assertNoMemoryAllocated}.
- *
- * The downside is that it's 100-1000x slower than the other variants.
- * Suggested use case: automated testing, regression testing, and interactive
- * debugging.
- */
-export const DEBUG_SYNC: SyncBuildVariant = {
-  type: "sync",
-  async importFFI() {
-    const mod = await import("./generated/ffi.WASM_DEBUG_SYNC.js")
-    return unwrapTypescript(mod).QuickJSFFI
-  },
-  async importModuleLoader() {
-    const mod = await import("./generated/emscripten-module.WASM_DEBUG_SYNC.js")
-    return unwrapJavascript(mod).default
-  },
-}
-
-/**
  * This is the default (synchronous) build variant.
  * {@link getQuickJS} returns a memoized instance of this build variant.
  */
@@ -163,24 +137,6 @@
     return unwrapJavascript(mod).default
   },
 }
-
-/**
- * The async debug build variant may or may not have the sanitizer enabled.
- * It does print a lot of debug logs.
- *
- * Suggested use case: interactive debugging only.
- */
-export const DEBUG_ASYNC: AsyncBuildVariant = {
-  type: "async",
-  async importFFI() {
-    const mod = await import("./generated/ffi.WASM_DEBUG_ASYNCIFY.js")
-    return unwrapTypescript(mod).QuickJSAsyncFFI
-  },
-  async importModuleLoader() {
-    const mod = await import("./generated/emscripten-module.WASM_DEBUG_ASYNCIFY.js")
-    return unwrapJavascript(mod).default
-  },
-}
 
 /**
  * This is the default asyncified build variant.
--- a/ts/index.ts
+++ b/ts/index.ts
@@ -20,8 +20,6 @@
 import {
   newQuickJSWASMModule,
   newQuickJSAsyncWASMModule,
-  DEBUG_ASYNC,
-  DEBUG_SYNC,
   RELEASE_ASYNC,
   RELEASE_SYNC,
   SyncBuildVariant,
@@ -30,8 +28,6 @@
 export {
   newQuickJSWASMModule,
   newQuickJSAsyncWASMModule,
-  DEBUG_ASYNC,
-  DEBUG_SYNC,
   RELEASE_ASYNC,
   RELEASE_SYNC,
   SyncBuildVariant,
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@
 # https://stackoverflow.com/questions/21246165/how-to-break-a-string-across-lines-in-a-makefile-without-spaces/50863019#50863019
 VARY=PLATFORM RELEASE SYNC
 VARY_PLATFORM:=WASM NATIVE
-VARY_RELEASE:=DEBUG RELEASE
+VARY_RELEASE:=RELEASE
 VARY_SYNC:=SYNC ASYNCIFY
 
 WASM_VARIANTS=$(foreach RELEASE,$(VARY_RELEASE),$(addprefix WASM_$(RELEASE)_,$(VARY_SYNC)))
