@mostfeatured/dbi 0.2.6 → 0.2.7
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recursiveImport.d.ts","sourceRoot":"","sources":["../../../src/utils/recursiveImport.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAY,EAAE,MAAM,GAAE,MAAM,EAAoC,GAAG,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"recursiveImport.d.ts","sourceRoot":"","sources":["../../../src/utils/recursiveImport.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAY,EAAE,MAAM,GAAE,MAAM,EAAoC,GAAG,OAAO,CAAC,GAAG,CAAC,CA2BpJ"}
|
|
@@ -16,11 +16,23 @@ async function recursiveImport(folderPath, exts = [".js"], ignore = [".d.ts", ".
|
|
|
16
16
|
let relative = path_1.default.relative(dirName, filePath);
|
|
17
17
|
if (!relative.includes(`${path_1.default.sep}-`)) {
|
|
18
18
|
if (file.isDirectory()) {
|
|
19
|
-
await recursiveImport(filePath, exts);
|
|
19
|
+
await recursiveImport(filePath, exts, ignore);
|
|
20
20
|
}
|
|
21
21
|
else if (exts.some(i => file.name.endsWith(i)) && !ignore.some(i => file.name.endsWith(i))) {
|
|
22
|
-
// Use require for CommonJS compatibility
|
|
23
|
-
|
|
22
|
+
// Use require for CommonJS compatibility
|
|
23
|
+
// Wrap in try-catch for Bun compatibility - Bun throws "Missing 'default' export"
|
|
24
|
+
// but still executes the module's side effects (dbi.register calls)
|
|
25
|
+
try {
|
|
26
|
+
require(filePath);
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
// Ignore "Missing 'default' export" errors in Bun runtime
|
|
30
|
+
// The module's side effects still execute before the error is thrown
|
|
31
|
+
if (!e.message?.includes("Missing 'default' export") &&
|
|
32
|
+
!e.message?.includes("does not provide an export named 'default'")) {
|
|
33
|
+
throw e;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
24
36
|
}
|
|
25
37
|
}
|
|
26
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recursiveImport.js","sourceRoot":"","sources":["../../../src/utils/recursiveImport.ts"],"names":[],"mappings":";;AAOA,
|
|
1
|
+
{"version":3,"file":"recursiveImport.js","sourceRoot":"","sources":["../../../src/utils/recursiveImport.ts"],"names":[],"mappings":";;AAOA,0CA2BC;;AAlCD,oDAAoB;AACpB,wDAAwB;AAExB;;;GAGG;AACI,KAAK,UAAU,eAAe,CAAC,UAAkB,EAAE,OAAiB,CAAC,KAAK,CAAC,EAAE,SAAmB,CAAC,OAAO,EAAC,SAAS,EAAC,WAAW,CAAC;IACpI,IAAI,KAAK,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3E,IAAI,OAAO,GAAG,SAAS,CAAC;IAExB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,QAAQ,GAAG,cAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,QAAQ,GAAG,cAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAChD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,cAAI,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;YACvC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;gBACvB,MAAM,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YAChD,CAAC;iBAAM,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC7F,yCAAyC;gBACzC,kFAAkF;gBAClF,oEAAoE;gBACpE,IAAI,CAAC;oBACH,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACpB,CAAC;gBAAC,OAAO,CAAM,EAAE,CAAC;oBAChB,0DAA0D;oBAC1D,qEAAqE;oBACrE,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,0BAA0B,CAAC;wBAChD,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,4CAA4C,CAAC,EAAE,CAAC;wBACvE,MAAM,CAAC,CAAC;oBACV,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import fs from \"fs\";\r\nimport path from \"path\";\r\n\r\n/**\r\n * @example\r\n * await recursiveImport(\"./src\", [\".js\"], [\".d.ts\"])\r\n */\r\nexport async function recursiveImport(folderPath: string, exts: string[] = [\".js\"], ignore: string[] = [\".d.ts\",\".js.map\",\".d.ts.map\"]): Promise<any> {\r\n let files = await fs.promises.readdir(folderPath, { withFileTypes: true });\r\n let dirName = __dirname;\r\n\r\n for (const file of files) {\r\n let filePath = path.resolve(folderPath, file.name);\r\n let relative = path.relative(dirName, filePath);\r\n if (!relative.includes(`${path.sep}-`)) {\r\n if (file.isDirectory()) {\r\n await recursiveImport(filePath, exts, ignore);\r\n } else if (exts.some(i => file.name.endsWith(i)) && !ignore.some(i => file.name.endsWith(i))) {\r\n // Use require for CommonJS compatibility\r\n // Wrap in try-catch for Bun compatibility - Bun throws \"Missing 'default' export\"\r\n // but still executes the module's side effects (dbi.register calls)\r\n try {\r\n require(filePath);\r\n } catch (e: any) {\r\n // Ignore \"Missing 'default' export\" errors in Bun runtime\r\n // The module's side effects still execute before the error is thrown\r\n if (!e.message?.includes(\"Missing 'default' export\") && \r\n !e.message?.includes(\"does not provide an export named 'default'\")) {\r\n throw e;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}"]}
|
package/package.json
CHANGED
|
@@ -14,10 +14,21 @@ export async function recursiveImport(folderPath: string, exts: string[] = [".js
|
|
|
14
14
|
let relative = path.relative(dirName, filePath);
|
|
15
15
|
if (!relative.includes(`${path.sep}-`)) {
|
|
16
16
|
if (file.isDirectory()) {
|
|
17
|
-
await recursiveImport(filePath, exts)
|
|
17
|
+
await recursiveImport(filePath, exts, ignore);
|
|
18
18
|
} else if (exts.some(i => file.name.endsWith(i)) && !ignore.some(i => file.name.endsWith(i))) {
|
|
19
|
-
// Use require for CommonJS compatibility
|
|
20
|
-
|
|
19
|
+
// Use require for CommonJS compatibility
|
|
20
|
+
// Wrap in try-catch for Bun compatibility - Bun throws "Missing 'default' export"
|
|
21
|
+
// but still executes the module's side effects (dbi.register calls)
|
|
22
|
+
try {
|
|
23
|
+
require(filePath);
|
|
24
|
+
} catch (e: any) {
|
|
25
|
+
// Ignore "Missing 'default' export" errors in Bun runtime
|
|
26
|
+
// The module's side effects still execute before the error is thrown
|
|
27
|
+
if (!e.message?.includes("Missing 'default' export") &&
|
|
28
|
+
!e.message?.includes("does not provide an export named 'default'")) {
|
|
29
|
+
throw e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
21
32
|
}
|
|
22
33
|
}
|
|
23
34
|
}
|