You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Got implemented in a way that does not put the code in the main lib
importalasqlfrom'alasql.js';// Import the pre-compiled function source code using a Bun macro.// This will execute compileToJS(sql) at build time and inline the result.import{compileToJS}from'alasql/precompile'with{type: 'macro'};constsql='SELECT product, price*100 AS calculated_price FROM ? where price > ? ORDER BY calculated_price DESC';// Create a function from the source code.// We bind `alasql` to `this` so the compiled function can find it.constselectProducts=newFunction('return '+compileToJS(sql))().bind(alasql);constdata=[{product: 'Ball',price: 3},{product: 'Pen',price: 1.5},];// Example of howto pass parameters to the compiled functionconstminPrice=2;// Execute the functionconstresult=selectProducts([data,minPrice]);console.log(result);
Activity
Extract compiled JS from SQL for #2169 (#2170)
mathiasrw commentedon Nov 17, 2025
Got implemented in a way that does not put the code in the main lib