@@ -5,10 +5,37 @@ import { fileURLToPath } from 'url';
55import { dirname , resolve } from 'path' ;
66
77/**
8- * Builds the project using esbuild .
8+ * Build the CLI enabled version of Tinny .
99 * @returns {Promise<void> } A promise that resolves when the build is complete.
1010 */
1111export const build = async ( ) => {
12+ await esbuild . build ( {
13+ entryPoints : [ fileURLToPath ( new URL ( './test.ts' , import . meta. url ) ) ] ,
14+ outfile : fileURLToPath ( new URL ( './build/test.mjs' , import . meta. url ) ) ,
15+ bundle : true ,
16+ plugins : [
17+ nodeExternalsPlugin ( {
18+ allowList : [
19+ 'ethers' ,
20+ '@lit-protocol/accs-schemas' ,
21+ '@lit-protocol/contracts' ,
22+ 'crypto' ,
23+ 'secp256k1' ,
24+ ] ,
25+ } ) ,
26+ ] ,
27+ platform : 'node' ,
28+ target : 'esnext' ,
29+ format : 'esm' ,
30+ inject : [ fileURLToPath ( new URL ( './shim.mjs' , import . meta. url ) ) ] ,
31+ mainFields : [ 'module' , 'main' ] ,
32+ } ) ;
33+ } ;
34+
35+ /**
36+ * Bundle Tinny to be a standalone package.
37+ */
38+ export const bundle = async ( ) => {
1239 await esbuild . build ( {
1340 entryPoints : [ fileURLToPath ( new URL ( './index.ts' , import . meta. url ) ) ] ,
1441 outfile : fileURLToPath ( new URL ( './index.js' , import . meta. url ) ) ,
@@ -37,5 +64,6 @@ export const build = async () => {
3764( async ( ) => {
3865 const start = Date . now ( ) ;
3966 await build ( ) ;
67+ await bundle ( ) ;
4068 console . log ( `[build.mjs] 🚀 Build time: ${ Date . now ( ) - start } ms` ) ;
4169} ) ( ) ;
0 commit comments