From 7e33c5ecaafbf0fbec2a902629acf469747c5478 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 21 Feb 2023 11:10:09 -0600 Subject: [PATCH] fix: update package.json to properly handle bringing in exports with import or require --- package.json | 10 ++++++---- scripts/create_dist_package_json.sh | 11 +++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 scripts/create_dist_package_json.sh diff --git a/package.json b/package.json index 7d4fbfe..718f06f 100644 --- a/package.json +++ b/package.json @@ -33,11 +33,13 @@ "package.json" ], "main": "dist/cjs/index.js", + "module": "dist/esm/index.js", "types": "dist/types/index.d.ts", "exports": { - "import": "./dist/esm/index.js", - "require": "./dist/cjs/index.js", - "default": "./dist/cjs/index.js" + ".": { + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.js" + } }, "scripts": { "clean": "rimraf dist", @@ -45,7 +47,7 @@ "lint-fix": "eslint --fix --ignore-path .eslintignore --ext .js,.ts . --max-warnings=0", "format-staged": "pretty-quick --staged", "format": "pretty-quick", - "build": "npm run tests && npm run clean && tsc --project tsconfig.cjs.json && tsc --project tsconfig.esm.json", + "build": "npm run tests && npm run clean && tsc --project tsconfig.cjs.json && tsc --project tsconfig.esm.json && ./scripts/create_dist_package_json.sh", "test:unit": "mocha -r ts-node/register", "test:integration": "mocha -r ts-node/register -r integrationTests/mochaRootHooks.ts", "tests:unit": "mocha -R progress -r ts-node/register ./tests/**/*.spec.ts", diff --git a/scripts/create_dist_package_json.sh b/scripts/create_dist_package_json.sh new file mode 100644 index 0000000..716fd35 --- /dev/null +++ b/scripts/create_dist_package_json.sh @@ -0,0 +1,11 @@ +cat > dist/cjs/package.json < dist/mjs/package.json <