diff --git a/package.json b/package.json index 3fd6bc0..a9dbe11 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,16 @@ "name": "@andrewmacmurray/elm-concurrent-task", "version": "1.0.0", "description": "Run a tree of Tasks concurrently, call JS functions as Tasks (Task Ports)", - "main": "lib/index.js", - "types": "lib/index.d.ts", + "main": "lib/cjs/index.js", + "module": "lib/mjs/index.js", + "types": "lib/mjs/index.d.ts", + "exports": { + ".": { + "import": "./lib/mjs/index.js", + "require": "./lib/cjs/index.js", + "types": "./lib/mjs/index.d.ts" + } + }, "files": [ "lib" ], @@ -14,7 +22,7 @@ "review": "elm-review --fix", "review:ci": "elm-review", "review:watch": "elm-review --watch", - "runner:compile": "tsc", + "runner:compile": "rm -rf lib/* && tsc -p tsconfig-mjs.json && tsc -p tsconfig-cjs.json && ./scripts/package-fixup.sh", "check-versions": "node ./scripts/versions.js" }, "author": "Andrew MacMurray", diff --git a/runner/http/fetch.ts b/runner/http/fetch.ts index 48663bb..dc5dd06 100644 --- a/runner/http/fetch.ts +++ b/runner/http/fetch.ts @@ -15,7 +15,11 @@ export function http(request: HttpRequest): Promise { signal: controller?.signal, }) .then((res: Response) => { - const headers = Object.fromEntries(res.headers.entries()); + const headers: { [key: string]: string } = {}; + res.headers.forEach((val, key) => { + headers[key] = val; + }); + switch (request.expect) { case "STRING": { return res.text().then((x) => ({ diff --git a/scripts/package-fixup.sh b/scripts/package-fixup.sh new file mode 100755 index 0000000..c0c82bd --- /dev/null +++ b/scripts/package-fixup.sh @@ -0,0 +1,15 @@ +#! /bin/bash + +# Adds package.json files to cjs/mjs subtrees + +cat >lib/cjs/package.json <lib/mjs/package.json <