diff options
author | stephan <stephan@noemail.net> | 2022-11-20 05:36:52 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-11-20 05:36:52 +0000 |
commit | 6d97c1a844f297043c0ca49e117af599dd0915ff (patch) | |
tree | ec846429bb929b55d55b25da0e03680ff153aa93 /ext/wasm/api/extern-post-js.js | |
parent | 59a9654715f0dd8e20f9de8ddd97c4f52f391ce9 (diff) | |
download | sqlite-6d97c1a844f297043c0ca49e117af599dd0915ff.tar.gz sqlite-6d97c1a844f297043c0ca49e117af599dd0915ff.zip |
Further minor cleanups in the JS build related to vanilla vs ESM.
FossilOrigin-Name: 100a596800eca61477d9880092465d594c22be3707f2a11aaf6eb9e234fc6f2d
Diffstat (limited to 'ext/wasm/api/extern-post-js.js')
-rw-r--r-- | ext/wasm/api/extern-post-js.js | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/ext/wasm/api/extern-post-js.js b/ext/wasm/api/extern-post-js.js index acf7068fe..cace6ed51 100644 --- a/ext/wasm/api/extern-post-js.js +++ b/ext/wasm/api/extern-post-js.js @@ -13,19 +13,20 @@ const toExportForES6 = //#endif (function(){ /** - In order to hide the sqlite3InitModule()'s resulting Emscripten - module from downstream clients (and simplify our documentation by - being able to elide those details), we rewrite - sqlite3InitModule() to return the sqlite3 object. + In order to hide the sqlite3InitModule()'s resulting + Emscripten module from downstream clients (and simplify our + documentation by being able to elide those details), we hide that + function and expose a hand-written sqlite3InitModule() to return + the sqlite3 object (most of the time). Unfortunately, we cannot modify the module-loader/exporter-based impls which Emscripten installs at some point in the file above this. */ const originalInit = - /*Maintenance reminde: DO NOT use `self.` here. It's correct - for non-ES6 Module cases but wrong for ES6 modules because those - resolve this symbol differently! */ sqlite3InitModule; + /* Maintenance reminder: DO NOT use `self.` here. It's correct + for non-ES6 Module cases but wrong for ES6 modules because those + resolve this symbol differently. */ sqlite3InitModule; if(!originalInit){ throw new Error("Expecting self.sqlite3InitModule to be defined by the Emscripten build."); } @@ -104,10 +105,11 @@ const toExportForES6 = } /* Replace the various module exports performed by the Emscripten glue... */ - if (typeof exports === 'object' && typeof module === 'object') + if (typeof exports === 'object' && typeof module === 'object'){ module.exports = sqlite3InitModule; - else if (typeof exports === 'object') + }else if (typeof exports === 'object'){ exports["sqlite3InitModule"] = sqlite3InitModule; + } /* AMD modules get injected in a way we cannot override, so we can't handle those here. */ return self.sqlite3InitModule /* required for ESM */; |