4
4
* Verification script to test both CommonJS and ESM imports work correctly
5
5
*/
6
6
7
- console . log ( ' 🧪 Testing twilio-node ESM support...\n' ) ;
7
+ console . log ( " 🧪 Testing twilio-node ESM support...\n" ) ;
8
8
9
9
// Test CommonJS
10
- console . log ( ' 📦 Testing CommonJS import...' ) ;
10
+ console . log ( " 📦 Testing CommonJS import..." ) ;
11
11
try {
12
- const twilio = require ( ' ../lib/index.js' ) ;
13
- console . log ( ' ✅ CommonJS import successful' ) ;
12
+ const twilio = require ( " ../lib/index.js" ) ;
13
+ console . log ( " ✅ CommonJS import successful" ) ;
14
14
console . log ( ` - Default export type: ${ typeof twilio } ` ) ;
15
- console . log ( ` - Twilio class available: ${ typeof twilio . Twilio === 'function' } ` ) ;
16
- console . log ( ` - JWT utilities available: ${ typeof twilio . jwt === 'object' } ` ) ;
17
- console . log ( ` - TwiML utilities available: ${ typeof twilio . twiml === 'object' } ` ) ;
18
- console . log ( ` - Webhook validation available: ${ typeof twilio . validateBody === 'function' } ` ) ;
15
+ console . log (
16
+ ` - Twilio class available: ${ typeof twilio . Twilio === "function" } `
17
+ ) ;
18
+ console . log (
19
+ ` - JWT utilities available: ${ typeof twilio . jwt === "object" } `
20
+ ) ;
21
+ console . log (
22
+ ` - TwiML utilities available: ${ typeof twilio . twiml === "object" } `
23
+ ) ;
24
+ console . log (
25
+ ` - Webhook validation available: ${
26
+ typeof twilio . validateBody === "function"
27
+ } `
28
+ ) ;
19
29
} catch ( error ) {
20
- console . log ( ' ❌ CommonJS import failed:' , error . message ) ;
30
+ console . log ( " ❌ CommonJS import failed:" , error . message ) ;
21
31
process . exit ( 1 ) ;
22
32
}
23
33
24
- console . log ( ' \n📦 Testing ESM dynamic import...' ) ;
34
+ console . log ( " \n📦 Testing ESM dynamic import..." ) ;
25
35
// Test ESM with dynamic import (works in both CommonJS and ESM contexts)
26
- import ( ' ../lib-esm/index.js' )
36
+ import ( " ../lib-esm/index.js" )
27
37
. then ( ( esm ) => {
28
- console . log ( ' ✅ ESM import successful' ) ;
38
+ console . log ( " ✅ ESM import successful" ) ;
29
39
console . log ( ` - Default export type: ${ typeof esm . default } ` ) ;
30
- console . log ( ` - Named Twilio export: ${ typeof esm . Twilio === 'function' } ` ) ;
31
- console . log ( ` - Named JWT export: ${ typeof esm . jwt === 'object' } ` ) ;
32
- console . log ( ` - Named TwiML export: ${ typeof esm . twiml === 'object' } ` ) ;
33
- console . log ( ` - Named validateBody export: ${ typeof esm . validateBody === 'function' } ` ) ;
34
-
35
- console . log ( '\n🎉 All tests passed! ESM support is working correctly.' ) ;
36
- console . log ( '\n📚 Usage examples:' ) ;
40
+ console . log (
41
+ ` - Named Twilio export: ${ typeof esm . Twilio === "function" } `
42
+ ) ;
43
+ console . log ( ` - Named JWT export: ${ typeof esm . jwt === "object" } ` ) ;
44
+ console . log ( ` - Named TwiML export: ${ typeof esm . twiml === "object" } ` ) ;
45
+ console . log (
46
+ ` - Named validateBody export: ${
47
+ typeof esm . validateBody === "function"
48
+ } `
49
+ ) ;
50
+
51
+ console . log ( "\n🎉 All tests passed! ESM support is working correctly." ) ;
52
+ console . log ( "\n📚 Usage examples:" ) ;
37
53
console . log ( ' CommonJS: const twilio = require("twilio");' ) ;
38
54
console . log ( ' ESM: import twilio from "twilio";' ) ;
39
55
console . log ( ' ESM: import { Twilio, jwt, twiml } from "twilio";' ) ;
40
56
} )
41
57
. catch ( ( error ) => {
42
- console . log ( ' ❌ ESM import failed:' , error . message ) ;
58
+ console . log ( " ❌ ESM import failed:" , error . message ) ;
43
59
process . exit ( 1 ) ;
44
- } ) ;
60
+ } ) ;
0 commit comments