@vinzsocket/baileys 3.0.20 → 3.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,11 @@
1
- const major = parseInt(process.versions.node.split('.')[0], 10);
1
+ const [major, minor] = process.versions.node.split('.').map(Number);
2
+
3
+ // require(esm) is only stable on Node 20.19.0+ and 22.12.0+ (and any 23.x+).
4
+ // Below that, `require('@vinzsocket/baileys')` from a CommonJS bot will throw ERR_REQUIRE_ESM.
5
+ const supportsRequireEsm =
6
+ major >= 23 ||
7
+ (major === 22 && minor >= 12) ||
8
+ (major === 20 && minor >= 19);
2
9
 
3
10
  if (major < 20) {
4
11
  console.error(
@@ -8,3 +15,13 @@ if (major < 20) {
8
15
  );
9
16
  process.exit(1);
10
17
  }
18
+
19
+ if (!supportsRequireEsm) {
20
+ console.warn(
21
+ `\n⚠️ Node.js ${process.versions.node} detected.\n` +
22
+ ` This package is ESM ("type": "module"). If your bot uses require() to load it,\n` +
23
+ ` you need Node.js 20.19.0+ or 22.12.0+ for require(esm) support.\n` +
24
+ ` Either upgrade Node.js, or load this package with dynamic import() instead:\n` +
25
+ ` const baileys = await import('@vinzsocket/baileys')\n`
26
+ );
27
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vinzsocket/baileys",
3
3
  "type": "module",
4
- "version": "3.0.20",
4
+ "version": "3.0.25",
5
5
  "description": "A WebSockets library for interacting with WhatsApp Web",
6
6
  "keywords": [
7
7
  "whatsapp",
@@ -136,4 +136,4 @@
136
136
  "engines": {
137
137
  "node": ">=20.0.0"
138
138
  }
139
- }
139
+ }