File tree Expand file tree Collapse file tree 3 files changed +30
-6
lines changed Expand file tree Collapse file tree 3 files changed +30
-6
lines changed Original file line number Diff line number Diff line change @@ -78,10 +78,33 @@ try {
7878 }
7979} ;
8080
81+ /**
82+ * Adds crypto polyfill to health check build
83+ */
84+ export const postBuildHealthPolyfill = ( ) => {
85+ try {
86+ const file = fs . readFileSync ( `./${ TEST_DIR } /build/health/index.mjs` , 'utf8' ) ;
87+ const content = `// Additional crypto polyfill check
88+ try {
89+ if (!globalThis.crypto && typeof webcrypto !== 'undefined') {
90+ globalThis.crypto = webcrypto;
91+ }
92+ } catch (error) {
93+ console.error('❌ Error in crypto polyfill', error);
94+ }
95+ ` ;
96+ const newFile = content + file ;
97+ fs . writeFileSync ( `./${ TEST_DIR } /build/health/index.mjs` , newFile ) ;
98+ } catch ( e ) {
99+ throw new Error ( `Error in postBuildHealthPolyfill: ${ e } ` ) ;
100+ }
101+ } ;
102+
81103// Go!
82104( async ( ) => {
83105 const start = Date . now ( ) ;
84106 await build ( ) ;
85107 postBuildPolyfill ( ) ;
108+ postBuildHealthPolyfill ( ) ;
86109 console . log ( `[build.mjs] 🚀 Build time: ${ Date . now ( ) - start } ms` ) ;
87110} ) ( ) ;
Original file line number Diff line number Diff line change 11import { createLitStatusClient } from '@lit-protocol/lit-status-sdk' ;
22import { DatilHealthManager } from './DatilHealthManager' ;
33
4- // Fix for Node.js crypto in ESM
5- import { webcrypto } from 'node:crypto' ;
6- if ( ! globalThis . crypto ) {
7- globalThis . crypto = webcrypto as Crypto ;
8- }
9-
104// Configuration
115const NETWORK = process . env . NETWORK ! ;
126const PRODUCT = 'js-sdk/datil' ;
Original file line number Diff line number Diff line change 11import { createRequire } from 'module' ;
2+ import { webcrypto } from 'node:crypto' ;
3+
24const require = createRequire ( import . meta. url ) ;
35global . require = require ;
6+
7+ // Add crypto polyfill for Node.js
8+ if ( ! globalThis . crypto ) {
9+ globalThis . crypto = webcrypto ;
10+ }
You can’t perform that action at this time.
0 commit comments