Alex2Node/package.json
David 70072d39e3 build: the ES module build gets its own declarations
An ES module TypeScript consumer was given the CommonJS declarations in dist/types. With those,
`import alex2node from "alex2node"` compiled (module Node16) and then failed when Node loaded it: "The requested
module 'alex2node' does not provide an export named 'default'". The ES module build has named exports only.

tsconfig.esm.json now emits declarations next to dist/esm/*.js, under that directory's {"type": "module"}, and
"exports" selects per condition: import -> dist/esm/index.d.ts, require -> dist/types/index.d.ts. The default
import is now refused with TS1192; named imports are unchanged. "main", "module" and "types" are as before.

test/fixtures/types.mts holds the default import under @ts-expect-error, and a new test requires "types" before
"default" and a declaration for every built file. dist/: 25 files, 132,291 B -> 33 files, 155,647 B; the npm
tarball 25,125 B -> 25,837 B. npm test: 25 pass in 5.6 s.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-28 14:31:34 +00:00

64 lines
1.5 KiB
JSON

{
"name": "alex2node",
"version": "1.5.2",
"description": "A Node.js library for creating Alexa-compatible devices using MQTT, based on Alex2MQTT.",
"type": "commonjs",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"exports": {
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/types/index.d.ts",
"default": "./dist/cjs/index.js"
}
},
"./package.json": "./package.json"
},
"sideEffects": false,
"engines": {
"node": ">=18"
},
"scripts": {
"build": "node scripts/build.mjs",
"check": "tsc --noEmit && tsc -p test/fixtures/tsconfig.json",
"prepare": "npm run build",
"test": "node --test test/*.test.js test/*.test.mjs"
},
"keywords": [
"alexa",
"mqtt",
"smart-home",
"iot",
"home-automation",
"amazon-alexa",
"alex2mqtt"
],
"author": "user511",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://git.stormysdream.club/apps/Alex2Node.git"
},
"bugs": {
"url": "https://git.stormysdream.club/apps/Alex2Node/issues"
},
"homepage": "https://git.stormysdream.club/apps/Alex2Node#readme",
"devDependencies": {
"@types/node": "^18.19.130",
"aedes": "^0.51.3",
"dotenv": "^16.5.0",
"typescript": "^5.8.3"
},
"dependencies": {
"mqtt": "^5.10.3"
},
"files": [
"dist",
"readme.md"
]
}