aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/extern-post-js.c-pp.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2023-01-28 04:20:46 +0000
committerstephan <stephan@noemail.net>2023-01-28 04:20:46 +0000
commit65f7942d0678a56f788d54a636c9c30ed63b5ee6 (patch)
treed3d7ad55512c95b9ca137d605d7e0b760f8bf687 /ext/wasm/api/extern-post-js.c-pp.js
parentcfd01014d0b5657a8b48d4c828405703cce9e941 (diff)
parent69141f52be6368d3510b551c74029e3600b6f4c2 (diff)
downloadsqlite-65f7942d0678a56f788d54a636c9c30ed63b5ee6.tar.gz
sqlite-65f7942d0678a56f788d54a636c9c30ed63b5ee6.zip
Add JS bundler-friendly JS build. Minor test code cleanups.
FossilOrigin-Name: 24d3a53dea5e596230558e233cbbd9d0288b4c394cd5ea7b650fd99bff4cde2e
Diffstat (limited to 'ext/wasm/api/extern-post-js.c-pp.js')
-rw-r--r--ext/wasm/api/extern-post-js.c-pp.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/ext/wasm/api/extern-post-js.c-pp.js b/ext/wasm/api/extern-post-js.c-pp.js
index 225869794..a577a63e1 100644
--- a/ext/wasm/api/extern-post-js.c-pp.js
+++ b/ext/wasm/api/extern-post-js.c-pp.js
@@ -9,7 +9,7 @@
Emscripten-generated module init scope, in the current
global scope. */
//#if target=es6-module
-const toExportForES6 =
+const toExportForESM =
//#endif
(function(){
/**
@@ -45,10 +45,10 @@ const toExportForES6 =
moduleScript: self?.document?.currentScript,
isWorker: ('undefined' !== typeof WorkerGlobalScope),
location: self.location,
- urlParams: new URL(self.location.href).searchParams
+ urlParams: new URL(self.location.href).searchParams
});
initModuleState.debugModule =
- (new URL(self.location.href).searchParams).has('sqlite3.debugModule')
+ initModuleState.urlParams.has('sqlite3.debugModule')
? (...args)=>console.warn('sqlite3.debugModule:',...args)
: ()=>{};
@@ -105,6 +105,10 @@ const toExportForES6 =
document?.currentScript?.src);
}
}
+//#ifnot target=es6-module
+// Emscripten does not inject these module-loader bits in ES6 module
+// builds and including them here breaks JS bundlers, so elide them
+// from ESM builds.
/* Replace the various module exports performed by the Emscripten
glue... */
if (typeof exports === 'object' && typeof module === 'object'){
@@ -114,8 +118,9 @@ const toExportForES6 =
}
/* AMD modules get injected in a way we cannot override,
so we can't handle those here. */
+//#endif // !target=es6-module
return self.sqlite3InitModule /* required for ESM */;
})();
//#if target=es6-module
-export default toExportForES6;
+export default toExportForESM;
//#endif