@@ -126,3 +126,87 @@ type KZGProofWithCells = {
126126 cells: string [] // Array of 128 cells, each 2048 bytes
127127}
128128` ` `
129+
130+ ## Development
131+
132+ ### Build Process
133+
134+ This section outlines the build scripts included in this repository to create distributable JavaScript/TypeScript packages from the WASM compilation.
135+
136+ #### Prerequisites
137+
138+ Ensure you have the following installed:
139+ - **Node.js** (v16+)
140+ - **npm**
141+ - **TypeScript** (installed as dev dependency)
142+ - **Babel** (installed as dev dependency)
143+
144+ #### Build Scripts Overview
145+
146+ The repository includes the following build scripts:
147+
148+ 1. ** ` build ` ** - Main build command
149+ 2. ** ` build : ts ` ** - TypeScript compilation to multiple targets
150+ 3. ** ` transpileCJS ` ** - Babel transpilation for CommonJS compatibility
151+ 4. ** ` fixRequire ` ** - Fix dynamic require statements
152+ 5. ** ` fixWasmDirInNode ` ** - Fix WASM paths for Node.js builds
153+ 6. ** ` fixWasmDirInWeb ` ** - Fix WASM paths for browser builds
154+
155+ #### Script Details
156+
157+ ** ` build : ts ` ** ( ` scripts /ts -build .sh ` )
158+ - Copies WASM file to ` dist /wasm /`
159+ - Compiles TypeScript to CommonJS ( ` dist /cjs /` )
160+ - Compiles TypeScript to ESM ( ` dist /esm /` )
161+ - Creates browser build ( ` dist /browser /` )
162+
163+ ** ` transpileCJS ` **
164+ - Uses Babel to transpile ` src /kzg .js ` to ` dist /cjs /`
165+ - Ensures CommonJS compatibility
166+
167+ ** ` fixRequire ` **
168+ - Fixes dynamic require statements in CommonJS build
169+ - Replaces ` \_require (' url' )` with ` require (' url' )`
170+
171+ ** ` fixWasmDirInNode ` **
172+ - Updates WASM file paths in Node.js builds
173+ - Changes ` kzg -node .wasm ` → ` kzg .wasm ` → ` ../wasm /kzg .wasm `
174+
175+ ** ` fixWasmDirInWeb ` **
176+ - Updates WASM file paths in browser builds
177+ - Changes ` kzg -web .wasm ` → ` ../wasm /kzg .wasm `
178+
179+ #### Build Output Structure
180+
181+ ` ` `
182+ dist /
183+ ├── cjs / # CommonJS build for Node .js
184+ │ ├── index .js
185+ │ ├── kzg .js
186+ │ ├── loader .cjs
187+ │ └── package .json
188+ ├── esm / # ES Modules build
189+ │ ├── index .js
190+ │ ├── kzg .js
191+ │ ├── loader .mjs
192+ │ └── package .json
193+ ├── browser / # Browser build
194+ │ ├── index .js
195+ │ ├── kzg .js
196+ │ └── package .json
197+ └── wasm / # WASM binary
198+ └── kzg .wasm
199+ ` ` `
200+
201+ #### Testing Builds
202+
203+ ` ` ` bash
204+ # Test all builds
205+ npm test
206+
207+ # Test specific builds
208+ npm run test :dist # Test distribution build
209+ npm run test :src # Test source code
210+ npm run test :browser # Test browser environment
211+ ```
212+
0 commit comments