From 66e7731e840afe5c63f3b3b6ff8d55b49b1779e5 Mon Sep 17 00:00:00 2001 From: Martin Hansen Date: Tue, 19 Sep 2023 12:49:07 +0200 Subject: [PATCH] Add explicit type in package.json --- .../inquirer-autocomplete-standalone/package.json | 3 ++- .../scripts/build-module-fixup.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 packages/inquirer-autocomplete-standalone/scripts/build-module-fixup.js diff --git a/packages/inquirer-autocomplete-standalone/package.json b/packages/inquirer-autocomplete-standalone/package.json index cea1fe8..b7b4a7c 100644 --- a/packages/inquirer-autocomplete-standalone/package.json +++ b/packages/inquirer-autocomplete-standalone/package.json @@ -3,6 +3,7 @@ "description": "Standalone autocomplete cli prompt based on inquirer core", "version": "0.3.0", "main": "./dist/cjs/index.js", + "module": "./dist/esm/index.js", "typings": "./dist/cjs/types/index.d.ts", "files": [ "dist/**/*" @@ -78,7 +79,7 @@ "pretest": "npm run lint", "test": "vitest run test --coverage", "tsc": "yarn run clean && yarn run tsc:esm && yarn run tsc:cjs", - "build": "yarn run tsc", + "build": "yarn run tsc && node ./scripts/build-module-fixup.js", "clean": "rm -rf dist", "tsc:esm": "tsc -p ./tsconfig.json", "tsc:cjs": "tsc -p ./tsconfig.cjs.json", diff --git a/packages/inquirer-autocomplete-standalone/scripts/build-module-fixup.js b/packages/inquirer-autocomplete-standalone/scripts/build-module-fixup.js new file mode 100644 index 0000000..61d23d3 --- /dev/null +++ b/packages/inquirer-autocomplete-standalone/scripts/build-module-fixup.js @@ -0,0 +1,14 @@ +import { writeFile } from 'node:fs/promises'; + +Promise.all([ + writeFile( + './dist/esm/package.json', + JSON.stringify({ type: 'module' }, null, 2), + 'utf8' + ), + writeFile( + './dist/cjs/package.json', + JSON.stringify({ type: 'commonjs' }, null, 2), + 'utf8' + ), +]);