MCPcopy
hub / github.com/BuilderIO/mitosis / generateCode

Function generateCode

packages/fiddle/src/components/Fiddle/generate.ts:3–95  ·  view source on GitHub ↗
({
  output,
  options,
}: {
  output: string;
  options: any;
})

Source from the content-addressed store, hash-verified

1type Transpiler = import('@builder.io/mitosis').Transpiler<string>;
2
3export const generateCode = async ({
4 output,
5 options,
6}: {
7 output: string;
8 options: any;
9}): Promise<Transpiler> => {
10 const mitosisCore = await import('@builder.io/mitosis');
11
12 const {
13 compileAwayBuilderComponents,
14 mapStyles,
15 componentToLiquid,
16 componentToAlpine,
17 componentToHtml,
18 componentToCustomElement,
19 componentToPreact,
20 componentToLit,
21 componentToRsc,
22 componentToQwik,
23 componentToReact,
24 componentToStencil,
25 componentToMarko,
26 componentToSwift,
27 componentToReactNative,
28 componentToTemplate,
29 componentToSolid,
30 componentToAngular,
31 componentToSvelte,
32 componentToMitosis,
33 componentToBuilder,
34 componentToVue,
35 } = mitosisCore;
36
37 const plugins = [
38 compileAwayBuilderComponents(),
39 mapStyles({
40 map: (styles) => ({
41 ...styles,
42 boxSizing: undefined,
43 flexShrink: undefined,
44 alignItems: styles.alignItems === 'stretch' ? undefined : styles.alignItems,
45 }),
46 }),
47 ];
48 const allOptions = { plugins, ...options };
49 switch (output) {
50 case 'liquid':
51 return componentToLiquid(allOptions);
52 case 'alpine':
53 return componentToAlpine(allOptions);
54 case 'html':
55 return componentToHtml(allOptions);
56 case 'webcomponents':
57 return componentToCustomElement(allOptions);
58 case 'preact':
59 return componentToPreact(allOptions);
60 case 'lit':

Callers

nothing calls this directly

Calls 15

mapStylesFunction · 0.85
componentToLiquidFunction · 0.85
componentToAlpineFunction · 0.85
componentToHtmlFunction · 0.85
componentToCustomElementFunction · 0.85
componentToPreactFunction · 0.85
componentToLitFunction · 0.85
componentToRscFunction · 0.85
componentToQwikFunction · 0.85
componentToReactFunction · 0.85
componentToStencilFunction · 0.85

Tested by

no test coverage detected