Skip to content

Commit

Permalink
break: add "exports" map for native ESM support (#6)
Browse files Browse the repository at this point in the history
* Support importing totalist/sync from es modules

Currently when I'm trying to import `totalist/sync` from
es module in node I get this error

```
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '.../node_modules/totalist/sync' is not supported resolving ES modules imported from my-script.js
Did you mean to import totalist/sync/index.js?
```

Exports field will help to fix this.

* Update package.json

Co-authored-by: Luke Edwards <[email protected]>
  • Loading branch information
TrySound and lukeed authored Jan 17, 2022
1 parent 4437997 commit 0dfdc59
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
"module": "dist/index.mjs",
"main": "dist/index.js",
"types": "index.d.ts",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"./sync": {
"import": "./sync/index.mjs",
"require": "./sync/index.js"
}
},
"license": "MIT",
"files": [
"index.d.ts",
Expand Down

0 comments on commit 0dfdc59

Please sign in to comment.