You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20Lines changed: 20 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -61,6 +61,26 @@ queue.enqueue(3);
61
61
console.log(queue.dequeue()); // Output: 3
62
62
```
63
63
64
+
### 🚧 Using `dslib-core` in CommonJS Projects
65
+
66
+
`dslib-core` is primarily designed for ESM (ECMAScript Module) environments. However, you can still use it in CommonJS projects with a few adjustments.
67
+
68
+
To use `dslib-core` in a CommonJS project, we suggest using a dynamic `import()` within an async IIFE (Immediately Invoked Function Expression). Here's an example:
69
+
70
+
```typescript
71
+
// CommonJS project example
72
+
(asyncfunction () {
73
+
const { Queue } =awaitimport('dslib-core');
74
+
75
+
// Your code here
76
+
const queue =newQueue();
77
+
queue.enqueue(1);
78
+
console.log(queue.dequeue()); // Output: 1
79
+
})();
80
+
```
81
+
82
+
This approach allows you to use the ESM-native `dslib-core` package within your CommonJS environment while maintaining asynchronous module loading.
0 commit comments