mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Allow mods to write appendices
Module local values are visible to Appendixes. This mechanism can be used for mods.
This commit is contained in:
@@ -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.");
|
||||
Reference in New Issue
Block a user