mobile: load async scripts with script manager

This commit is contained in:
Ammar Ahmed
2024-10-16 16:12:18 +05:00
parent 7e1146fb7c
commit 2b98b5d5f2
2 changed files with 19 additions and 1 deletions

View File

@@ -5,4 +5,21 @@ import "./polyfills/console-time.js"
global.Buffer = require('buffer').Buffer;
import '../app/common/logger/index';
import { DOMParser } from './worker.js';
import { ScriptManager, Script } from '@callstack/repack/client';
global.DOMParser = DOMParser;
ScriptManager.shared.addResolver(async (scriptId) => {
// `scriptId` will be either 'student' or 'teacher'
// In dev mode, resolve script location to dev server.
if (__DEV__) {
return {
url: Script.getDevServerURL(scriptId),
cache: false,
};
}
return {
url: Script.getFileSystemURL(scriptId)
};
});

View File

@@ -118,6 +118,7 @@
"terser-webpack-plugin": "^5.3.5",
"ts-jest": "^29.1.1",
"webpack-cli": "^5.1.4",
"webpack": "^5.88.2"
"webpack": "^5.88.2",
"acorn-import-attributes": "1.9.5"
}
}