From ca6c26fbeb2c7f15c8f37618611d61cea5b51b3b Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Sat, 15 Jan 2022 12:39:18 +0300 Subject: [PATCH 1/2] 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. --- package.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/package.json b/package.json index 785fe60..fad74de 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,18 @@ "module": "dist/index.mjs", "main": "dist/index.js", "types": "index.d.ts", + "exports": { + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "default": "./dist/index.js" + }, + "./sync": { + "require": "./sync/index.js", + "import": "./sync/index.mjs", + "default": "./sync/index.js" + } + }, "license": "MIT", "files": [ "index.d.ts", From f64729b554769d152a596af4207eedf86279ec88 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Sun, 16 Jan 2022 18:49:39 -0800 Subject: [PATCH 2/2] Update package.json --- package.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index fad74de..595b8f2 100644 --- a/package.json +++ b/package.json @@ -8,14 +8,12 @@ "types": "index.d.ts", "exports": { ".": { - "require": "./dist/index.js", "import": "./dist/index.mjs", - "default": "./dist/index.js" + "require": "./dist/index.js" }, "./sync": { - "require": "./sync/index.js", "import": "./sync/index.mjs", - "default": "./sync/index.js" + "require": "./sync/index.js" } }, "license": "MIT",