diff --git a/results.json b/results.json index ba9f88b..19f1eba 100644 --- a/results.json +++ b/results.json @@ -22,7 +22,7 @@ "7_scheduler": 10.645383548000012, "8_json_validator": 3.43886771999998, "9_stream_visualizer": 4.354729013999982, - "4_transpiler": 8.389267120000005 + "4_transpiler": 2.492613701999995 }, "openai/gpt-5.1-codex": { "10_scrypt_hash": 7.498817803999991, @@ -35,7 +35,7 @@ "7_scheduler": 79.01968128499995, "8_json_validator": 8.087602373000001, "9_stream_visualizer": 12.885421481000026, - "4_transpiler": 51.812796853999984 + "4_transpiler": 3.333252582000001 }, "moonshotai/kimi-k2-thinking": { "10_scrypt_hash": 53.01161044100009, @@ -48,7 +48,7 @@ "7_scheduler": 204.68869797400012, "8_json_validator": 282.8534934129999, "9_stream_visualizer": 445.8482685430001, - "4_transpiler": 25.871377203000012 + "4_transpiler": 281.009873894 }, "google/gemini-2.5-pro": { "10_scrypt_hash": 33.595784767000005, @@ -61,7 +61,7 @@ "7_scheduler": 98.78428086399985, "8_json_validator": 17.644947614999953, "9_stream_visualizer": 42.817067843999716, - "4_transpiler": 79.54909138500004 + "4_transpiler": 20.659448836000053 }, "openrouter/sherlock-think-alpha": { "10_scrypt_hash": 14.262482631000225, @@ -338,7 +338,7 @@ "7_scheduler": 79.87219575399999, "8_json_validator": 28.535885181999998, "9_stream_visualizer": 21.60573508199997, - "4_transpiler": 51.93870672 + "4_transpiler": 15.103792848000001 }, "x-ai/grok-4.1-fast": { "10_scrypt_hash": 7.757944809, @@ -351,7 +351,7 @@ "7_scheduler": 48.61515529499997, "8_json_validator": 36.715725561, "9_stream_visualizer": 20.464613763000003, - "4_transpiler": 90.58870585400001 + "4_transpiler": 15.495995939 }, "anthropic/claude-opus-4.5 TEMP:0.7": { "10_scrypt_hash": 3.390702887, @@ -364,7 +364,7 @@ "7_scheduler": 13.963300305999997, "8_json_validator": 3.6207129579999964, "9_stream_visualizer": 4.672214089000001, - "4_transpiler": 12.686495516999999 + "4_transpiler": 3.4918008779999994 }, "openrouter/bert-nebulon-alpha": { "10_scrypt_hash": 8.55691055, @@ -377,6 +377,6 @@ "7_scheduler": 22.426437961999998, "8_json_validator": 12.943359998, "9_stream_visualizer": 12.601481400000004, - "4_transpiler": 18.506576999999997 + "4_transpiler": 3.338363882 } -} +} \ No newline at end of file diff --git a/tests/4_transpiler/outputs/anthropic_claude-opus-4.5 TEMP_0.7.js b/tests/4_transpiler/outputs/anthropic_claude-opus-4.5 TEMP_0.7.js index 71925bc..303d459 100644 --- a/tests/4_transpiler/outputs/anthropic_claude-opus-4.5 TEMP_0.7.js +++ b/tests/4_transpiler/outputs/anthropic_claude-opus-4.5 TEMP_0.7.js @@ -1,75 +1,5 @@ -async function bundleApp(entryFile, files) { - const Babel = await import('https://esm.sh/@babel/standalone'); - const modules = {}; - const visited = new Set(); - - const resolve = (from, to) => { - if (!to.startsWith('./') && !to.startsWith('../')) return to; - const fromParts = from.split('/').slice(0, -1); - const toParts = to.split('/'); - for (const p of toParts) { - if (p === '..') fromParts.pop(); - else if (p !== '.') fromParts.push(p); - } - return fromParts.join('/') || toParts[toParts.length - 1]; - }; - - const extractDeps = code => { - const deps = []; - const re = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g; - let m; - while ((m = re.exec(code))) deps.push(m[1]); - return deps; - }; - - const process = file => { - if (visited.has(file)) return; - visited.add(file); - if (!(file in files)) throw new Error(`Missing file: ${file}`); - const transformed = Babel.transform(files[file], { - presets: ['env'], - filename: file - }).code; - const deps = extractDeps(transformed); - const resolved = {}; - for (const d of deps) { - const r = resolve(file, d); - resolved[d] = r; - process(r); - } - modules[file] = { code: transformed, deps: resolved }; - }; - - process(entryFile); - - const modulesObj = JSON.stringify( - Object.fromEntries( - Object.entries(modules).map(([k, v]) => [ - k, - { code: v.code, deps: v.deps } - ]) - ) - ); - - return `(function(){ -var __modules__=${modulesObj}; -var __cache__={}; -var __resolve__=function(f,t){ -var d=__modules__[f].deps; -return d[t]||t; -}; -var __require__=function(from,id){ -var resolved=__resolve__(from,id); -if(__cache__[resolved])return __cache__[resolved].exports; -var mod=__modules__[resolved]; -if(!mod)throw new Error("Cannot find module: "+resolved); -var module={exports:{}}; -__cache__[resolved]=module; -var fn=new Function("require","module","exports",mod.code); -fn(function(id){return __require__(resolved,id);},module,module.exports); -return module.exports; -}; -return __require__("","${entryFile}"); -})()`; +async function renderTemplate(template, data) { + const { default: Handlebars } = await import('https://esm.sh/handlebars'); + return Handlebars.compile(template)(data); } -export default bundleApp; \ No newline at end of file +export default renderTemplate; \ No newline at end of file diff --git a/tests/4_transpiler/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js b/tests/4_transpiler/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js index 3c9988e..2f44ea8 100644 --- a/tests/4_transpiler/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js +++ b/tests/4_transpiler/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js @@ -1,76 +1,9 @@ -async function bundleApp(entryFile, files) { - const { transform } = await import('https://unpkg.com/@babel/standalone/babel.min.js'); +async function renderTemplate(templateString, data) { + const { default: Handlebars } = await import( + 'https://cdn.jsdelivr.net/npm/handlebars@4.7.8/dist/handlebars.min.js' + ); - const modules = {}; - const visited = new Set(); - - const normalizePath = (path) => { - return path.replace(/^\.\//, '').replace(/\.js$/, '') + '.js'; - }; - - const extractRequires = (code) => { - const requires = []; - const regex = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g; - let match; - while ((match = regex.exec(code)) !== null) { - requires.push(match[1]); - } - return requires; - }; - - const traverse = (fileName) => { - const normalizedName = normalizePath(fileName); - - if (visited.has(normalizedName)) return; - if (!files[normalizedName]) { - throw new Error(`Missing file: ${normalizedName}`); - } - - visited.add(normalizedName); - - const transformed = transform(files[normalizedName], { - presets: ['env'] - }).code; - - modules[normalizedName] = transformed; - - const deps = extractRequires(transformed); - deps.forEach(dep => traverse(dep)); - }; - - traverse(entryFile); - - const moduleEntries = Object.entries(modules).map(([name, code]) => - `${JSON.stringify(name)}: function(require, module, exports) {\n${code}\n}` - ).join(',\n'); - - return `(function() { - const modules = { -${moduleEntries} - }; - - const cache = {}; - - function require(name) { - const normalized = name.replace(/^\.\//, '').replace(/\.js$/, '') + '.js'; - - if (cache[normalized]) { - return cache[normalized].exports; - } - - if (!modules[normalized]) { - throw new Error('Module not found: ' + normalized); - } - - const module = { exports: {} }; - cache[normalized] = module; - - modules[normalized](require, module, module.exports); - - return module.exports; - } - - return require(${JSON.stringify(normalizePath(entryFile))}); -})();`; + const template = Handlebars.compile(templateString); + return template(data); } -export default bundleApp; \ No newline at end of file +export default renderTemplate; \ No newline at end of file diff --git a/tests/4_transpiler/outputs/google_gemini-2.5-pro.js b/tests/4_transpiler/outputs/google_gemini-2.5-pro.js index 956c8b2..2e07827 100644 --- a/tests/4_transpiler/outputs/google_gemini-2.5-pro.js +++ b/tests/4_transpiler/outputs/google_gemini-2.5-pro.js @@ -1,60 +1,5 @@ -const bundleApp = async (entryFile, files) => { - const Babel = (await import('https://cdn.jsdelivr.net/npm/@babel/standalone@7/babel.min.js')).default; - - const resolvePath = (base, relative) => { - if (!/^\./.test(relative)) return relative; - const stack = base.split('/').slice(0, -1); - relative.split('/').forEach(part => { - if (part === '..') stack.pop(); - else if (part !== '.') stack.push(part); - }); - return stack.join('/'); - }; - - const modules = []; - const moduleMap = new Map(); - - const createModule = async (filename) => { - if (moduleMap.has(filename)) return moduleMap.get(filename); - - const code = files[filename]; - if (code === undefined) throw new Error(`File not found: ${filename}`); - - const id = modules.length; - moduleMap.set(filename, id); - modules.push(null); - - const { code: transformedCode } = Babel.transform(code, { presets: ['env'] }); - const depRegex = /(? m[1]); - - const mapping = {}; - await Promise.all(dependencies.map(async depPath => { - const absPath = resolvePath(filename, depPath); - mapping[depPath] = await createModule(absPath); - })); - - modules[id] = { code: transformedCode, mapping }; - return id; - }; - - const entryId = await createModule(entryFile); - - const moduleDefs = modules.map( - ({ code, mapping }) => `[function(require,module,exports){${code}},${JSON.stringify(mapping)}]` - ).join(','); - - return `(function() { - const modules = [${moduleDefs}]; - const cache = {}; - const require = id => { - if (cache[id]) return cache[id].exports; - const [fn, mapping] = modules[id]; - const module = cache[id] = { exports: {} }; - fn(path => require(mapping[path]), module, module.exports); - return module.exports; - }; - return require(${entryId}); -})()`; +const renderTemplate = async (templateString, data) => { + const { default: Handlebars } = await import('https://cdn.jsdelivr.net/npm/handlebars@latest/dist/handlebars.min.js'); + return Handlebars.compile(templateString)(data); }; -export default bundleApp; \ No newline at end of file +export default renderTemplate; \ No newline at end of file diff --git a/tests/4_transpiler/outputs/google_gemini-3-pro-preview TEMP_0.35.js b/tests/4_transpiler/outputs/google_gemini-3-pro-preview TEMP_0.35.js index 512c281..32e16b4 100644 --- a/tests/4_transpiler/outputs/google_gemini-3-pro-preview TEMP_0.35.js +++ b/tests/4_transpiler/outputs/google_gemini-3-pro-preview TEMP_0.35.js @@ -1,36 +1,5 @@ -const bundleApp = async (entry, files) => { - const { transform } = await import('https://esm.sh/@babel/standalone'); - let id = 0, queue = [{ name: entry, id: id++ }], modules = []; - - for (const asset of queue) { - if (files[asset.name] == null) throw new Error(`Missing file: ${asset.name}`); - - const { code } = transform(files[asset.name], { presets: ['env'] }); - const map = {}; - - code.replace(/require\s*\(\s*['"](.+?)['"]\s*\)/g, (_, path) => { - const base = asset.name.split('/'), rel = path.split('/'); - base.pop(); - rel.forEach(p => p === '..' ? base.pop() : p !== '.' && base.push(p)); - const abs = base.join('/'); - - let child = queue.find(x => x.name === abs); - if (!child) queue.push(child = { name: abs, id: id++ }); - map[path] = child.id; - }); - - modules.push(`${asset.id}:[function(require,module,exports){${code}},${JSON.stringify(map)}]`); - } - - return `;(function(m){ - var c={}; - function r(i){ - if(c[i])return c[i].exports; - var mod=c[i]={exports:{}}, fn=m[i][0], map=m[i][1]; - fn(p=>r(map[p]||p), mod, mod.exports); - return mod.exports; - } - return r(0); - })({${modules.join(',')}})`; -}; -export default bundleApp; \ No newline at end of file +const renderTemplate = async (tmpl, data) => { + const { default: H } = await import('https://cdn.jsdelivr.net/npm/handlebars@latest/+esm') + return H.compile(tmpl)(data) +} +export default renderTemplate; \ No newline at end of file diff --git a/tests/4_transpiler/outputs/moonshotai_kimi-k2-thinking.js b/tests/4_transpiler/outputs/moonshotai_kimi-k2-thinking.js index 4145bf8..0902e30 100644 --- a/tests/4_transpiler/outputs/moonshotai_kimi-k2-thinking.js +++ b/tests/4_transpiler/outputs/moonshotai_kimi-k2-thinking.js @@ -1,41 +1,7 @@ -async function bundleApp(entryFile, files) { - const Babel = (await import("https://unpkg.com/@babel/standalone/babel.min.js")).default; - - const graph = new Map; - const processing = new Set; - - function resolve(from, to) { - if (!to.startsWith(".")) return to; - const parts = from.split("/"); - parts.pop(); - for (const p of to.split("/")) p === ".." ? parts.pop() : p && p !== "." && parts.push(p); - return parts.join("/"); - } - - function extract(code) { - const deps = []; - code.replace(/require\s*\(\s*["'`]([^"'`]+)["'`]\s*\)/g, (_, d) => deps.push(d)); - return deps; - } - - function walk(file) { - if (graph.has(file)) return; - if (processing.has(file)) throw new Error(`Circular: ${file}`); - if (!(file in files)) throw new Error(`Missing: ${file}`); - processing.add(file); - const code = Babel.transform(files[file], { presets: [["env", { modules: "cjs" }]] }).code; - const deps = extract(code).map(d => resolve(file, d)); - graph.set(file, { code, deps }); - deps.forEach(walk); - processing.delete(file); - } - - walk(entryFile); - - return `(function(){const modules={},cache={};function require(path){if(cache[path])return cache[path].exports;const module={exports:{}};cache[path]=module;const fn=modules[path];if(!fn) { - throw new Error('Missing: ' + path); - }fn(require,module,module.exports);return module.exports;} -${Array.from(graph, ([p, {code}]) => `modules['${p}']=(function(require,module,exports){\n${code}\n});`).join("\n")} -return require('${entryFile}');})()`; -} -export default bundleApp; \ No newline at end of file +let h, c = new Map(); +const renderTemplate = async (t, d) => { + h ||= (await import('https://cdn.jsdelivr.net/npm/handlebars@4.7.8/dist/handlebars.min.js')).default; + c.has(t) || c.set(t, h.compile(t)); + return c.get(t)(d); +}; +export default renderTemplate; \ No newline at end of file diff --git a/tests/4_transpiler/outputs/openai_gpt-5.1-codex.js b/tests/4_transpiler/outputs/openai_gpt-5.1-codex.js index b7d82f4..6597ec0 100644 --- a/tests/4_transpiler/outputs/openai_gpt-5.1-codex.js +++ b/tests/4_transpiler/outputs/openai_gpt-5.1-codex.js @@ -1,32 +1,5 @@ -const bundleApp=async(entry,files)=>{ - const {transform}=(await import('https://esm.sh/@babel/standalone@7.23.9')).default - const mods=new Map - const norm=(from,to)=>{ - if(!to.startsWith('.'))return to - const parts=from.split('/') - parts.pop() - to.split('/').forEach(part=>{ - if(!part||part=='.')return - part=='..'?parts.pop():parts.push(part) - }) - return parts.join('/') - } - const walk=file=>{ - if(mods.has(file))return - const src=files[file] - if(src==null)throw new Error(`Missing file: ${file}`) - const {code}=transform(src,{presets:[['env',{modules:'commonjs'}]],sourceType:'module'}) - const deps={} - for(const m of code.matchAll(/require\((['"])(.+?)\1\)/g)){ - const spec=m[2] - deps[spec]=norm(file,spec) - } - mods.set(file,{code,deps}) - Object.values(deps).forEach(walk) - } - walk(entry) - const esc=s=>s.replace(/\\/g,'\\\\').replace(/`/g,'\\`').replace(/\$\{/g,'\\${') - const body=[...mods].map(([id,{code,deps}])=>`"${id}":[function(require,module,exports){${esc(code)}},${JSON.stringify(deps)}]`).join(',') - return `(()=>{var m={${body}},c={},p=(f,s)=>{if(!s.startsWith('.'))return s;var a=f.split('/');a.pop();s.split('/').forEach(b=>{if(!b||b=='.')return;b=='..'?a.pop():a.push(b)});return a.join('/')},r=f=>{if(!m[f])throw new Error("Missing module "+f);if(c[f])return c[f].exports;var d=m[f],mod={exports:{}};c[f]=mod;d[0](g=>{var t=d[1][g];return r(t?t:p(f,g))},mod,mod.exports);return mod.exports};return r("${entry}")})()` +async function renderTemplate(t,d){ + const {default:h}=await import('https://cdn.jsdelivr.net/npm/handlebars@latest/+esm') + return h.compile(t)(d) } -export default bundleApp; \ No newline at end of file +export default renderTemplate; \ No newline at end of file diff --git a/tests/4_transpiler/outputs/openrouter_bert-nebulon-alpha.js b/tests/4_transpiler/outputs/openrouter_bert-nebulon-alpha.js index 2592dfa..61906de 100644 --- a/tests/4_transpiler/outputs/openrouter_bert-nebulon-alpha.js +++ b/tests/4_transpiler/outputs/openrouter_bert-nebulon-alpha.js @@ -1,62 +1,6 @@ -const bundleApp = async (entryFile, files) => { - const babel = await import('https://unpkg.com/@babel/standalone/babel.min.js'); - const graph = {}; - const visited = new Set(); - - const traverse = async (filename) => { - if (visited.has(filename)) return; - visited.add(filename); - - if (!files[filename]) throw new Error(`File not found: ${filename}`); - - const transformed = babel.transform(files[filename], { - presets: ['env'], - filename - }).code; - - const deps = []; - const requireRegex = /require\(['"](.*?)['"]\)/g; - let match; - - while ((match = requireRegex.exec(transformed)) !== null) { - deps.push(match[1]); - } - - graph[filename] = { code: transformed, deps }; - await Promise.all(deps.map(dep => traverse(resolvePath(filename, dep)))); - }; - - const resolvePath = (from, to) => { - if (to.startsWith('.')) { - const fromDir = from.split('/').slice(0, -1).join('/'); - return `${fromDir}/${to}`.replace(/\/\.\//g, '/').replace(/[^/]+\/\.\.\//g, ''); - } - return to; - }; - - await traverse(entryFile); - - const modules = Object.entries(graph).map(([id, { code }]) => { - return `'${id}': { - exports: {}, - fn: function(require, module, exports) { - ${code} - } - }`; - }).join(','); - - return `(function() { - const modules = {${modules}}; - const cache = {}; - - function require(moduleId) { - if (cache[moduleId]) return cache[moduleId].exports; - const module = cache[moduleId] = modules[moduleId]; - module.fn(require, module, module.exports); - return module.exports; - } - - return require('${entryFile}'); - })();`; -}; -export default bundleApp; \ No newline at end of file +const renderTemplate = async (template, data) => { + const { default: Handlebars } = await import('https://cdn.jsdelivr.net/npm/handlebars@latest/dist/handlebars.min.js') + const compiled = Handlebars.compile(template) + return compiled(data) +} +export default renderTemplate; \ No newline at end of file diff --git a/tests/4_transpiler/outputs/x-ai_grok-4.1-fast.js b/tests/4_transpiler/outputs/x-ai_grok-4.1-fast.js index e8e5dba..a829da6 100644 --- a/tests/4_transpiler/outputs/x-ai_grok-4.1-fast.js +++ b/tests/4_transpiler/outputs/x-ai_grok-4.1-fast.js @@ -1,92 +1,8 @@ -async function bundleApp(entryFile, files) { - const babel = await import('https://esm.sh/@babel/standalone@7.24.7'); - const { transform } = babel; - const modules = new Map(); - const visited = new Set(); - const reqRe = /require\s*\(\s*["']([^"']+)["']\s*\)/g; +const getHandlebars=(async()=>(await import('https://esm.sh/handlebars@4.7.8')).default)(); - function dirname(file) { - const i = file.lastIndexOf('/'); - return i === -1 ? '' : file.slice(0, i); - } - - function resolvePath(from, imp) { - const dirSegments = dirname(from).split('/'); - const impSegments = imp.split('/').filter(s => s !== '' && s !== '.'); - const resSegments = [...dirSegments]; - for (const seg of impSegments) { - if (seg === '..') { - resSegments.pop(); - } else { - resSegments.push(seg); - } - } - return resSegments.join('/'); - } - - function escapeRegExp(str) { - return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); - } - - function escapeStr(str) { - return str.replace(/\\/g, '\\\\').replace(/'/g, "\\'"); - } - - async function process(file) { - if (visited.has(file)) return; - visited.add(file); - const code = files[file]; - if (code === undefined) throw new Error(`Missing file: ${file}`); - const res = transform(code, { - presets: [['env', { modules: 'commonjs' }]], - filename: file - }); - if (res.error) throw new Error(`Babel error in ${file}: ${res.error}`); - let tcode = res.code; - const deps = new Set(); - let match; - while ((match = reqRe.exec(tcode)) !== null) { - deps.add(match[1]); - } - const rdeps = new Set([...deps].map(d => resolvePath(file, d))); - for (const orig of deps) { - const resolved = resolvePath(file, orig); - const re = new RegExp(`require\\s*\\(\\s*["']${escapeRegExp(orig)}["']\\s*\\)`, 'g'); - tcode = tcode.replace(re, `require("${resolved}")`); - } - modules.set(file, tcode); - await Promise.all(Array.from(rdeps).map(process)); - } - - const entryId = resolvePath('index.js', entryFile); - await process(entryId); - - const sortedModules = Array.from(modules.entries()).sort(([a], [b]) => a.localeCompare(b)); - const bundleParts = [ - '(function(){', - 'var modules={' - ]; - for (const [id, code] of sortedModules) { - bundleParts.push( - `'${escapeStr(id)}':function(r,m,e){`, - code, - '},' - ); - } - bundleParts.pop(); - bundleParts.push( - '};', - 'var cache={};', - 'function req(id){', - 'if(cache[id])return cache[id].exports;', - 'var m={exports:{}};', - 'cache[id]=m;', - 'modules[id].call(m.exports,req,m,m.exports);', - 'return m.exports;', - '}', - `return req('${escapeStr(entryId)}');`, - '})()' - ); - return bundleParts.join(''); +async function renderTemplate(template,data){ + const Handlebars=await getHandlebars; + const fn=Handlebars.compile(template); + return fn(data); } -export default bundleApp; \ No newline at end of file +export default renderTemplate; \ No newline at end of file