We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent eb3c8cf commit a18d1baCopy full SHA for a18d1ba
doc/api/packages.md
@@ -683,6 +683,32 @@ and in a CommonJS one. For example, this code will also work:
683
const { something } = require('a-package/foo'); // Loads from ./foo.js.
684
```
685
686
+Finally, self-referencing also works with scoped packages. For example, this
687
+code will also work:
688
+
689
+```json
690
+// package.json
691
+{
692
+ "name": "@my/package",
693
+ "exports": "./index.js"
694
+}
695
+```
696
697
+```js
698
+// ./index.js
699
+module.exports = 42
700
701
702
703
+// ./other.js
704
+console.log(require('@my/package'))
705
706
707
+```sh
708
+node other.js
709
+# 42
710
711
712
## Dual CommonJS/ES module packages
713
714
Prior to the introduction of support for ES modules in Node.js, it was a common
0 commit comments