char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
92d1bb0c9
char/aliceai-t5-moe
1import { build } from 'esbuild' ; 2import { dirname , resolve } from 'path' ; 3import { fileURLToPath } from 'url' ; 4import type { Plugin } from 'vite' ; 5 6const __dirname = dirname ( fileURLToPath ( import . meta. url )); 7const VENDORS_DIR = resolve ( __dirname , '../src/lib/vendors' ); 8const VIRTUAL_ID = 'virtual:nerdamer' ; 9const RESOLVED_ID = '\0' + VIRTUAL_ID ; 10 11/** 12* Bundle the vendored nerdamer-prime source into a minified IIFE string, 13* exposed as the `virtual:nerdamer` module. Flags mirror the upstream 14* build (esbuild --bundle --minify --format=iife --global-name=nerdamer), 15* so only human readable source lives in the repo and minification is a 16* build artifact. Vendored under src/lib/vendors/, upstream snapshot: 17* https://github.com/together-science/nerdamer-prime/commit/1936145f8af306ec0d883b9bfd7730aedd175c24 18*/ 19export function nerdamerPlugin () :Plugin { 20let bundled :string | null = null ; 21 22return { 23async load ( id ) { 24if ( id !== RESOLVED_ID ) return undefined ; 25 26if ( bundled === null ) { 27const result = await build ({ 28alias :{ 29'big-integer' :resolve ( VENDORS_DIR , 'big-integer/BigInteger.js' ), 30'decimal.js' :resolve ( VENDORS_DIR , 'decimal.js/decimal.js' ) 31}, 32bundle :true , 33entryPoints :[ resolve ( VENDORS_DIR , 'nerdamer-prime/all.js' )], 34format :'iife' , 35globalName :'nerdamer' , 36logLevel :'silent' , 37minify :true , 38write :false 39}); 40 41bundled = result . outputFiles [ 0 ]. text ; 42} 43 44return `export default ${ JSON . stringify ( bundled )} ;` ; 45}, 46name :'llamacpp:nerdamer' , 47resolveId ( id ) { 48return id === VIRTUAL_ID ?RESOLVED_ID :undefined ; 49} 50}; 51}