We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 00f2cee commit 2624c98Copy full SHA for 2624c98
doc/api/packages.md
@@ -664,6 +664,32 @@ and in a CommonJS one. For example, this code will also work:
664
const { something } = require('a-package/foo'); // Loads from ./foo.js.
665
```
666
667
+Finally, self-referencing also works with scoped packages. For example, this
668
+code will also work:
669
+
670
+```json
671
+// package.json
672
+{
673
+ "name": "@my/package",
674
+ "exports": "./index.js"
675
+}
676
+```
677
678
+```js
679
+// ./index.js
680
+module.exports = 42;
681
682
683
684
+// ./other.js
685
+console.log(require('@my/package'));
686
687
688
+```console
689
+$ node other.js
690
+42
691
692
693
## Dual CommonJS/ES module packages
694
695
Prior to the introduction of support for ES modules in Node.js, it was a common
0 commit comments