Revert "Cache the scripts on disk, in attempt to increase perfrmance, may need to revisit this"

This reverts commit 4a335dc936.
This commit is contained in:
Peter Stockings
2025-07-26 21:53:31 +10:00
parent 4a335dc936
commit 2fbace641d
5 changed files with 77 additions and 95 deletions

View File

@@ -8,7 +8,7 @@ const States = Object.freeze({
});
self.onmessage = async (e) => {
const { filePath, request, environment, name } = e.data;
const { code, request, environment, name } = e.data;
const logs: any[] = [];
const startTime = performance.now();
@@ -52,7 +52,15 @@ self.onmessage = async (e) => {
status
);
const userModule = await import(filePath);
let userModule = moduleCache.get(code);
if (!userModule) {
// Use a data URL to import the user's code as an ES module.
const dataUrl = `data:text/javascript;base64,${btoa(
unescape(encodeURIComponent(code))
)}`;
userModule = await import(dataUrl);
moduleCache.set(code, userModule);
}
if (typeof userModule.default !== "function") {
throw new Error(