Allow mods to write appendices

Module local values are visible to Appendixes. This mechanism can be
used for mods.
This commit is contained in:
phosit
2025-01-25 08:48:52 +01:00
committed by phosit
parent d76e107dca
commit 4043f954a7
7 changed files with 97 additions and 1 deletions
@@ -0,0 +1,4 @@
export function fn()
{
return "Base";
}
@@ -0,0 +1 @@
throw new Error("This script should't be evaluated.");
@@ -0,0 +1,7 @@
// Even though this is local to the module, it's visible to other appendixes.
function appendToResult(fun, str)
{
return () => fun() + str;
}
fn = appendToResult(fn, "0");
@@ -0,0 +1,4 @@
if (import.meta.path !== "modified/base.js")
throw new Error("import.meta.path should be the path of the base.");
fn = appendToResult(fn, "1");
@@ -0,0 +1 @@
throw new Error("This script should't be evaluated.");