|
3 | 3 | * Run with: node bundler-test/test-cjs-import.cjs |
4 | 4 | */ |
5 | 5 |
|
6 | | -console.log('Testing CommonJS require() compatibility...\n'); |
| 6 | +console.log("Testing CommonJS require() compatibility...\n"); |
7 | 7 |
|
8 | 8 | // Use standard CommonJS require |
9 | 9 | let wasmUtxo; |
10 | 10 | try { |
11 | | - wasmUtxo = require('../dist/cjs/index.js'); |
| 11 | + wasmUtxo = require("../dist/cjs/index.js"); |
12 | 12 | } catch (error) { |
13 | | - console.error('✗ require() failed:', error.message); |
| 13 | + console.error("✗ require() failed:", error.message); |
14 | 14 | process.exit(1); |
15 | 15 | } |
16 | 16 |
|
17 | | -console.log('✓ require() successful from CJS context'); |
18 | | -console.log('✓ Available exports:', Object.keys(wasmUtxo).join(', ')); |
| 17 | +console.log("✓ require() successful from CJS context"); |
| 18 | +console.log("✓ Available exports:", Object.keys(wasmUtxo).join(", ")); |
19 | 19 |
|
20 | 20 | // Test that we can access the main APIs |
21 | 21 | if (wasmUtxo.Descriptor) { |
22 | | - console.log('✓ Descriptor API available'); |
| 22 | + console.log("✓ Descriptor API available"); |
23 | 23 | } |
24 | 24 | if (wasmUtxo.Psbt) { |
25 | | - console.log('✓ Psbt API available'); |
| 25 | + console.log("✓ Psbt API available"); |
26 | 26 | } |
27 | 27 | if (wasmUtxo.address) { |
28 | | - console.log('✓ address namespace available'); |
| 28 | + console.log("✓ address namespace available"); |
29 | 29 | } |
30 | 30 | if (wasmUtxo.fixedScriptWallet) { |
31 | | - console.log('✓ fixedScriptWallet namespace available'); |
| 31 | + console.log("✓ fixedScriptWallet namespace available"); |
32 | 32 | } |
33 | 33 |
|
34 | 34 | // Try to use the Descriptor API |
35 | 35 | try { |
36 | 36 | const descriptor = wasmUtxo.Descriptor.fromString( |
37 | | - 'wpkh(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/0/*)', |
38 | | - 'derivable' |
| 37 | + "wpkh(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/0/*)", |
| 38 | + "derivable", |
39 | 39 | ); |
40 | | - console.log('✓ Descriptor.fromString() works'); |
41 | | - console.log(' Descriptor type:', descriptor.descType()); |
| 40 | + console.log("✓ Descriptor.fromString() works"); |
| 41 | + console.log(" Descriptor type:", descriptor.descType()); |
42 | 42 | } catch (err) { |
43 | | - console.log('✗ Descriptor test failed:', err.message); |
| 43 | + console.log("✗ Descriptor test failed:", err.message); |
44 | 44 | process.exit(1); |
45 | 45 | } |
46 | 46 |
|
47 | | -console.log('\n✅ All CJS compatibility tests passed!'); |
48 | | -console.log('\nCJS consumers can use standard require() with this package.'); |
49 | | - |
| 47 | +console.log("\n✅ All CJS compatibility tests passed!"); |
| 48 | +console.log("\nCJS consumers can use standard require() with this package."); |
0 commit comments