We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0e55a75 commit fe4d562Copy full SHA for fe4d562
doc/api/packages.md
@@ -709,6 +709,32 @@ and in a CommonJS one. For example, this code will also work:
709
const { something } = require('a-package/foo'); // Loads from ./foo.js.
710
```
711
712
+Finally, self-referencing also works with scoped packages. For example, this
713
+code will also work:
714
+
715
+```json
716
+// package.json
717
+{
718
+ "name": "@my/package",
719
+ "exports": "./index.js"
720
+}
721
+```
722
723
+```js
724
+// ./index.js
725
+module.exports = 42;
726
727
728
729
+// ./other.js
730
+console.log(require('@my/package'));
731
732
733
+```console
734
+$ node other.js
735
+42
736
737
738
## Dual CommonJS/ES module packages
739
740
Prior to the introduction of support for ES modules in Node.js, it was a common
0 commit comments