Merge pull request #3304 from danielyxie/revoke-fix

revoke-fix
This commit is contained in:
hydroflame 2022-03-30 21:43:43 -04:00 committed by GitHub
commit a0361c9a42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -30,6 +30,7 @@ export async function compile(player: IPlayer, script: Script, scripts: Script[]
const uurls = _getScriptUrls(script, scripts, []); const uurls = _getScriptUrls(script, scripts, []);
const url = uurls[uurls.length - 1].url; const url = uurls[uurls.length - 1].url;
if (script.url && script.url !== url) { if (script.url && script.url !== url) {
URL.revokeObjectURL(script.url);
// Thoughts: Should we be revoking any URLs here? // Thoughts: Should we be revoking any URLs here?
// If a script is modified repeatedly between two states, // If a script is modified repeatedly between two states,
// we could reuse the blob at a later time. // we could reuse the blob at a later time.
@ -42,8 +43,9 @@ export async function compile(player: IPlayer, script: Script, scripts: Script[]
// }); // });
// } // }
} }
script.url = url; if (script.dependencies.length > 0) script.dependencies.forEach((dep) => URL.revokeObjectURL(dep.url));
script.module = new Promise((resolve) => resolve(eval("import(url)"))); script.url = uurls[uurls.length - 1].url;
script.module = new Promise((resolve) => resolve(eval("import(uurls[uurls.length - 1].url)")));
script.dependencies = uurls; script.dependencies = uurls;
} }