upd: make the mod tracker work in dev mode

this is an ugly hack but it's a ugly hack that works.
This commit is contained in:
ShittyKopper 2024-01-15 18:11:03 +03:00
parent 8702c1dd24
commit f58f0eaf92
3 changed files with 10 additions and 1 deletions

View File

@ -16,3 +16,4 @@ declare const _DATA_TRANSFER_DECK_COLUMN_: string;
// for dev-mode // for dev-mode
declare const _LANGS_FULL_: string[][]; declare const _LANGS_FULL_: string[][];
declare const __DIRNAME__: string;

View File

@ -233,7 +233,14 @@ export class ChiptuneJsPlayer {
async createLibopenmptNode(buffer: ArrayBuffer) { async createLibopenmptNode(buffer: ArrayBuffer) {
if (!this.libopenmpt) { if (!this.libopenmpt) {
const libopenmpt = await import('libopenmpt-wasm'); const libopenmpt = await import('libopenmpt-wasm');
this.libopenmpt = await libopenmpt.default(); this.libopenmpt = await libopenmpt.default( _DEV_ ? {
// hack to make libopenmpt load in dev mode
locateFile(file) {
const url = new URL(window.location.href);
url.pathname = `/@fs/${__DIRNAME__}/node_modules/libopenmpt-wasm/${file}`;
return url.href;
},
} : {});
} }
return new ChiptuneProcessorNode(this, buffer); return new ChiptuneProcessorNode(this, buffer);

View File

@ -55,6 +55,7 @@ const devConfig = {
define: { define: {
...defaultConfig.define, ...defaultConfig.define,
_LANGS_FULL_: JSON.stringify(Object.entries(locales)), _LANGS_FULL_: JSON.stringify(Object.entries(locales)),
__DIRNAME__: JSON.stringify(__dirname),
}, },
}; };