From 0cd38cd2b9adb966e4ff02596526725311fadf64 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 27 Jan 2023 01:33:12 +0000 Subject: Beginnings of a bundler-friendly build of sqlite3.mjs. Not yet ready for downstream testing. FossilOrigin-Name: 4271bf5f41df091696f1dcfc4ffe7a60d24066fc75c896941e0b56de95fe5f89 --- ext/wasm/api/extern-post-js.c-pp.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ext/wasm/api/extern-post-js.c-pp.js') diff --git a/ext/wasm/api/extern-post-js.c-pp.js b/ext/wasm/api/extern-post-js.c-pp.js index 225869794..87d99eaba 100644 --- a/ext/wasm/api/extern-post-js.c-pp.js +++ b/ext/wasm/api/extern-post-js.c-pp.js @@ -105,6 +105,10 @@ const toExportForES6 = document?.currentScript?.src); } } +//#ifnot target=es6-module +// Emscripten does not inject these module-loader bits in ES6 module +// build and including them here breaks JS bundlers, so elide them +// from ES6 builds. /* Replace the various module exports performed by the Emscripten glue... */ if (typeof exports === 'object' && typeof module === 'object'){ @@ -114,6 +118,7 @@ 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 -- cgit v1.2.3 From a0013fbe879fb59843c69610af56b5b9141c9614 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 27 Jan 2023 03:18:16 +0000 Subject: More work on creating a separate sqlite3.js build which is hopefully friendly to JS bundlers. FossilOrigin-Name: b7b896fb448a7f46eb88eadadb1359255aec637a384cabcdd526276a02f4f0b4 --- ext/wasm/api/extern-post-js.c-pp.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'ext/wasm/api/extern-post-js.c-pp.js') diff --git a/ext/wasm/api/extern-post-js.c-pp.js b/ext/wasm/api/extern-post-js.c-pp.js index 87d99eaba..691ad7685 100644 --- a/ext/wasm/api/extern-post-js.c-pp.js +++ b/ext/wasm/api/extern-post-js.c-pp.js @@ -45,14 +45,23 @@ const toExportForES6 = moduleScript: self?.document?.currentScript, isWorker: ('undefined' !== typeof WorkerGlobalScope), location: self.location, - urlParams: new URL(self.location.href).searchParams + urlParams: +//#if target=es6-bundler-friendly + undefined +//#else + new URL(self.location.href).searchParams +//#endif }); initModuleState.debugModule = - (new URL(self.location.href).searchParams).has('sqlite3.debugModule') +//#if target=es6-bundler-friendly + ()=>{} +//#else + (new URL(self.location.href).searchParams).has('sqlite3.debugModule') ? (...args)=>console.warn('sqlite3.debugModule:',...args) : ()=>{}; +//#endif - if(initModuleState.urlParams.has('sqlite3.dir')){ + if(initModuleState.urlParams && initModuleState.urlParams.has('sqlite3.dir')){ initModuleState.sqlite3Dir = initModuleState.urlParams.get('sqlite3.dir') +'/'; }else if(initModuleState.moduleScript){ const li = initModuleState.moduleScript.src.split('/'); -- cgit v1.2.3