From 9c27df3acf42d6afca71eb65536982d65ed56eff Mon Sep 17 00:00:00 2001 From: Reginald Alfret Date: Tue, 3 Nov 2026 15:13:28 +0530 Subject: [PATCH] Add package.json exports to support ES modules in Node Resolve #118 by adding an `exports` map to `package.json`. Modern Node.js environments and test runners (e.g. Vitest) using ES modules do not read the legacy "module" field and fall back to "main" (the UMD bundle), failing named imports (`SyntaxError: Named export '...' not found`). Adding standard conditional exports maps: - `types` -> `./types/index.d.ts` (for TypeScript resolution) - `import` -> `./dist/dap.esm.js` (for ESM imports in Node/bundlers) - `require` -> `./dist/dap.umd.js` (for CommonJS require) - `default` -> `./dist/dap.umd.js` - `./package.json` -> `./package.json` Existing legacy fields (`main`, `module`, `types`) remain intact for backwards compatibility with older tooling. Fixes #118 Signed-off-by: Reginald Alfret --- package.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/package.json b/package.json index 0ef8640..c52537d 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,15 @@ "main": "dist/dap.umd.js", "module": "dist/dap.esm.js", "types": "types/index.d.ts", + "exports": { + ".": { + "types": "./types/index.d.ts", + "import": "./dist/dap.esm.js", + "require": "./dist/dap.umd.js", + "default": "./dist/dap.umd.js" + }, + "./package.json": "./package.json" + }, "repository": { "type": "git", "url": "git://github.com/ARMmbed/dapjs.git"