Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Search Gists
Sign in Sign up

Instantly share code, notes, and snippets.

This document analyzes the bundle size of MoonBit JavaScript output, identifying the main contributors to code size and potential optimization opportunities.

Note: The analyzed output is after terser DCE (Dead Code Elimination) with compress enabled. Unused code has already been removed.

Analysis Target

https://github.com/mizchi/js.mbt/blob/main/src/examples/aisdk/main.mbt

/// original https://github.com/moonbit-community/jmop/blob/main/promise.mbt
///|
extern"js"fnffi_promise_resolve(x :Value)->Value="(x) => Promise.resolve(x)"
///|
extern"js"fnffi_promise_reject(e :Error)->Value="(x) => Promise.reject(x)"
///|
extern"js"fnffi_promise_then(
```mbt
asyncfn[T,U]map_async(arr:Array[T],f:async (T)->Uraise?)->Array[U]raise? {
letres:Array[U]= []
foriteminarr {
res.push(f(item))
}
res
}
asynctest {
///|
fnalias@svg.nodeassvg_node
///|
fn[M]common_svg_node(
tag_name :String,
new_attrs :Array[@svg.Attribute[M]],
style~ :Array[String]?,
class~ :String?,
id~ :String?,
constOPENAI_API_KEY_PATH="%_%=k";
constTEMP_PKCE_VERIFIER="%_%=pk";
functionbase64UrlEncode(array:Uint8Array):string{
constbase64=btoa(String.fromCharCode(...array));
returnbase64.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");
}
typeLoginState=
|{
/**
DiscordAuthforCloudflareAccess
basedon https://github.com/Erisa/discord-oidc-worker
#Creatediscordapplication
-Getclientidandsecret
-SetredirectURLto`https://<cloudflare-name>.cloudflareaccess.com/cdn-cgi/access/callback`
///|
test"String to Bytes conversion" {
fnfind_index(url :Bytes)->Int? {
url.find("://")
}
leturl="https://www.example.ocom"
leturl_bytes :Bytes="https://example.com"
inspect(url.find("://"),content="Some(5)")
inspect(find_index("https://example.com"),content="Some(5)")
NewerOlder

[8]ページ先頭

©2009-2025 Movatter.jp