Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic loader, Dexie ESM fix #315

Merged
merged 2 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading