MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / bundleSmokeHarness

Function bundleSmokeHarness

packages/hosts/mcp-apps-shell/src/vite.ts:99–125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

97 * render's answer must not depend on how the host was started.
98 */
99export const bundleSmokeHarness = async (): Promise<string> => {
100 const { build } = await import("esbuild");
101 const result = await build({
102 entryPoints: [smokeHarnessEntry()],
103 absWorkingDir: packageRoot,
104 bundle: true,
105 write: false,
106 format: "iife",
107 platform: "browser",
108 target: "es2022",
109 jsx: "automatic",
110 // NOT minified, deliberately. React builds the component stack from
111 // function names, and that stack is most of the value of what the model is
112 // told: "at ChartTooltipContent, at BarChart, at App" is a fix, "at cie, at
113 // Sg" is nothing. Minifying saves ~1MB of source text the sandbox parses in
114 // a few hundred milliseconds; the stack is worth more than that.
115 minify: false,
116 define: { "process.env.NODE_ENV": JSON.stringify("production") },
117 });
118
119 const js = result.outputFiles[0];
120 if (!js) {
121 // oxlint-disable-next-line executor/no-try-catch-or-throw, executor/no-error-constructor -- boundary: build helpers report failure by throwing
122 throw new Error("Failed to bundle the artifact smoke-render harness.");
123 }
124 return js.text;
125};
126
127/** Add to an app's `plugins` array to make the shell bundleable in that app. */
128export const innerRendererPlugin = (): InnerRendererVitePlugin => ({

Callers 1

Calls 1

smokeHarnessEntryFunction · 0.85

Tested by

no test coverage detected