From a4bd9f26c3bc71aab5359364031cf32b734908bb Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Sat, 7 Jun 2025 09:59:30 +0700 Subject: [PATCH] fix(scripts/build): use import instead of require for asset generation --- scripts/build.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/build.ts b/scripts/build.ts index e403bcc..f732ebf 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -234,10 +234,14 @@ async function generateAssets() { if (await exists(path2)) continue + // We attempt to sanitize the path, but not the name as it should fail if name contains invalid characters + const uriPath = JSON.stringify(path) + const type = JSON.stringify(ext.slice(1)) + promises.push( writeFile( path2, - `const ${name}=require('@revenge-mod/assets').registerAsset({name:'${name}',type:'${ext.slice(1)}',uri:require('~/../${path}')})/**@type {ReturnType}*/\nexport default ${name}`, + `import{registerAsset}from'@revenge-mod/assets';import uri from${uriPath};const ${name}=registerAsset({name:'${name}',type:${type},uri});export default ${name}`, ), ) }