1"use strict";(globalThis.webpackChunkdocs=globalThis.webpackChunkdocs||[]).push([[2578],{78839(e,n,r){r.r(n),r.d(n,{assets:()=>a,contentTitle:()=>s,default:()=>h,frontMatter:()=>c,metadata:()=>i,toc:()=>l});const i=JSON.parse('{"id":"reference/NoirJS/noir_wasm/functions/compile","title":"Function: compile()","description":"Compiles a Noir project","source":"@site/versioned_docs/version-v1.0.0-rc.0/reference/NoirJS/noir_wasm/functions/compile.md","sourceDirName":"reference/NoirJS/noir_wasm/functions","slug":"/reference/NoirJS/noir_wasm/functions/compile","permalink":"/docs/v1.0.0-rc.0/reference/NoirJS/noir_wasm/functions/compile","draft":false,"unlisted":false,"editUrl":"https://github.com/noir-lang/noir/edit/master/docs/versioned_docs/version-v1.0.0-rc.0/reference/NoirJS/noir_wasm/functions/compile.md","tags":[],"version":"v1.0.0-rc.0","frontMatter":{},"sidebar":"sidebar","previous":{"title":"noir_wasm","permalink":"/docs/v1.0.0-rc.0/reference/NoirJS/noir_wasm/"},"next":{"title":"Function: compile\\\\_contract()","permalink":"/docs/v1.0.0-rc.0/reference/NoirJS/noir_wasm/functions/compile_contract"}}');var o=r(74848),t=r(28453);const c={},s="Function: compile()",a={},l=[{value:"Parameters",id:"parameters",level:2},{value:"Returns",id:"returns",level:2},{value:"Example",id:"example",level:2}];function d(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,t.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.header,{children:(0,o.jsx)(n.h1,{id:"function-compile",children:"Function: compile()"})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-ts",children:"function compile(\n fileManager, \n projectPath?, \n logFn?, \ndebugLogFn?): Promise<ProgramCompilationArtifacts>;\n"})}),"\n",(0,o.jsx)(n.p,{children:"Compiles a Noir project"}),"\n",(0,o.jsx)(n.h2,{id:"parameters",children:"Parameters"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{children:"Parameter"}),(0,o.jsx)(n.th,{children:"Type"}),(0,o.jsx)(n.th,{children:"Description"})]})}),(0,o.jsxs)(n.tbody,{children:[(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"fileManager"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"FileManager"})}),(0,o.jsx)(n.td,{children:"The file manager to use"})]}),(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"projectPath?"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"string"})}),(0,o.jsx)(n.td,{children:"The path to the project inside the file manager. Defaults to the root of the file manager"})]}),(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"logFn?"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"LogFn"})}),(0,o.jsx)(n.td,{children:"A logging function. If not provided, console.log will be used"})]}),(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"debugLogFn?"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"LogFn"})}),(0,o.jsx)(n.td,{children:"A debug logging function. If not provided, logFn will be used"})]})]})]}),"\n",(0,o.jsx)(n.h2,{id:"returns",children:"Returns"}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.code,{children:"Promise"}),"<",(0,o.jsx)(n.a,{href:"/docs/v1.0.0-rc.0/reference/NoirJS/noir_wasm/#programcompilationartifacts",children:(0,o.jsx)(n.code,{children:"ProgramCompilationArtifacts"})}),">"]}),"\n",(0,o.jsx)(n.h2,{id:"example",children:"Example"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-typescript",children:"// Node.js\n\nimport { compile_program, createFileManager } from '@noir-lang/noir_wasm';\n\nconst fm = createFileManager(myProjectPath);\nconst myCompiledCode = await compile_program(fm);\n"})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-typescript",children:"// Browser\n\nimport { compile_program, createFileManager } from '@noir-lang/noir_wasm';\n\nconst fm = createFileManager('/');\nfor (const path of files) {\n await fm.writeFile(path, await getFileAsStream(path));\n}\nconst myCompiledCode = await compile_program(fm);\n"})})]})}function h(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(d,{...e})}):d(e)}},28453(e,n,r){r.d(n,{R:()=>c,x:()=>s});var i=r(96540);const o={},t=i.createContext(o);function c(e){const n=i.useContext(t);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:c(e.components),i.createElement(t.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.