aboutsummaryrefslogtreecommitdiff
path: root/docs/runtime/modules.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/runtime/modules.md')
-rw-r--r--docs/runtime/modules.md14
1 files changed, 6 insertions, 8 deletions
diff --git a/docs/runtime/modules.md b/docs/runtime/modules.md
index dd48dfa46..349fd3594 100644
--- a/docs/runtime/modules.md
+++ b/docs/runtime/modules.md
@@ -201,6 +201,12 @@ const myStuff = require("./my-commonjs.cjs");
const { stuff } = require("./my-esm.mjs");
```
+### Importing CommonJS from CommonJS
+
+```ts
+const { stuff } = require("./my-commonjs.cjs");
+```
+
#### Top-level await
If you are using top-level await, you must use `import()` to import ESM modules from CommonJS modules.
@@ -218,14 +224,6 @@ const { stuff } = require("./my-esm.js");
Bun's JavaScript runtime has native support for CommonJS. When Bun's JavaScript transpiler detects usages of `module.exports`, it treats the file as CommonJS. The module loader will then wrap the transpiled module in a function shaped like this:
-### Importing CommonJS from CommonJS
-
-You can `require()` CommonJS modules from CommonJS modules.
-
-```ts
-const { stuff } = require("./my-commonjs.cjs");
-```
-
```js
(function (module, exports, require) {
// transpiled module