Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 36 additions & 8 deletions test/js-scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,45 @@
/**
* ESBuild configuration for building individual TypeScript utility modules
* for a Node.js environment. Builds are run concurrently for optimization.
*/
const { build } = require("esbuild");

// List of entry points (base names of the TypeScript files in src/).
const entryPoints = ["getModifyLiquidityResult", "getSqrtPriceAtTick", "getTickAtSqrtPrice"];

// Shared configuration applied to all build targets.
const sharedConfig = {
bundle: true,
minify: false,
bundle: true, // Bundle all dependencies into a single file
minify: false, // Keep the output unminified (set to true for production)
platform: "node", // Target Node.js environment
};

for (const entryPoint of entryPoints) {
build({
entryPoints: [`src/${entryPoint}.ts`],
...sharedConfig,
platform: "node",
outfile: `dist/${entryPoint}.js`,
/**
* Executes the ESBuild process concurrently for all defined entry points.
*/
async function runBuilds() {
const buildPromises = entryPoints.map((entryPoint) => {
const inputFile = `src/${entryPoint}.ts`;
const outputFile = `dist/${entryPoint}.js`;

console.log(`Building: ${inputFile} -> ${outputFile}`);

return build({
entryPoints: [inputFile],
...sharedConfig,
outfile: outputFile,
});
});

try {
// Run all builds concurrently and wait for all Promises to resolve.
await Promise.all(buildPromises);
console.log("✅ All builds completed successfully.");
} catch (error) {
console.error("❌ ESBuild failed during compilation:", error);
process.exit(1); // Exit with a non-zero code on failure
}
}

// Execute the main build function.
runBuilds();