Skip to content

Commit

Permalink
Merge pull request #315 from jbukl/dynamic-loader-modules
Browse files Browse the repository at this point in the history
Dynamic loader, Dexie ESM fix
  • Loading branch information
djahandarie authored Nov 12, 2023
2 parents 382f2ec + 99a4b37 commit f263e99
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 21 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"source.fixAll.eslint": true,
},
"eslint.format.enable": true,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"javascript.preferences.importModuleSpecifierEnding": "js",
}
17 changes: 0 additions & 17 deletions dev/lib/dexie-export-import.js

This file was deleted.

5 changes: 4 additions & 1 deletion dev/lib/dexie.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
export * from 'dexie';
import Dexie from 'dexie';
import 'dexie-export-import';

export {Dexie};
2 changes: 1 addition & 1 deletion ext/js/pages/settings/backup-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import * as Dexie from '../../../lib/dexie.js';
import {Dexie} from '../../../lib/dexie.js';
import {isObject, log} from '../../core.js';
import {OptionsUtil} from '../../data/options-util.js';
import {ArrayBufferUtil} from '../../data/sandbox/array-buffer-util.js';
Expand Down
2 changes: 1 addition & 1 deletion ext/js/script/dynamic-loader-sentinel.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

import {yomichan} from '../yomichan.js';

yomichan.trigger('dynamicLoaderSentinel', {script: document.currentScript});
yomichan.trigger('dynamicLoaderSentinel', {script: import.meta.url});
3 changes: 2 additions & 1 deletion ext/js/script/dynamic-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export const dynamicLoader = (() => {
if (node !== null) { continue; }

const script = document.createElement('script');
script.type = 'module';
script.async = false;
script.src = url;
parent.appendChild(script);
Expand All @@ -140,7 +141,7 @@ export const dynamicLoader = (() => {

const sentinelEventName = 'dynamicLoaderSentinel';
const sentinelEventCallback = (e) => {
if (e.script !== script) { return; }
if (e.script !== script.src) { return; }
yomichan.off(sentinelEventName, sentinelEventCallback);
parent.removeChild(script);
resolve();
Expand Down

0 comments on commit f263e99

Please sign in to comment.