diff --git a/packages/shared/common/package.json b/packages/shared/common/package.json index e1bfe9b94b..d81ea23fff 100644 --- a/packages/shared/common/package.json +++ b/packages/shared/common/package.json @@ -19,8 +19,14 @@ "client" ], "exports": { - "require": { "types": "./dist/cjs/index.d.ts", "default": "./dist/cjs/index.cjs"}, - "import": { "types": "./dist/esm/index.d.ts", "default": "./dist/esm/index.mjs"} + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.cjs" + }, + "import": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.mjs" + } }, "scripts": { "test": "npx jest --ci", diff --git a/packages/shared/sdk-client/package.json b/packages/shared/sdk-client/package.json index f327ce81d9..1d832d82f0 100644 --- a/packages/shared/sdk-client/package.json +++ b/packages/shared/sdk-client/package.json @@ -2,8 +2,8 @@ "name": "@launchdarkly/js-client-sdk-common", "version": "1.9.0", "type": "module", - "main": "./dist/index.mjs", - "types": "./dist/index.d.ts", + "main": "./dist/esm/index.mjs", + "types": "./dist/esm/index.d.ts", "homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/shared/sdk-client", "repository": { "type": "git", @@ -19,14 +19,22 @@ "client" ], "exports": { - "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", - "import": "./dist/index.mjs" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.cjs" + }, + "import": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.mjs" + } }, "scripts": { "doc": "../../../scripts/build-doc.sh .", "test": "npx jest --ci", - "build": "tsc --noEmit && rollup -c rollup.config.js", + "make-cjs-package-json": "echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json", + "make-esm-package-json": "echo '{\"type\":\"module\"}' > dist/esm/package.json", + "make-package-jsons": "npm run make-cjs-package-json && npm run make-esm-package-json", + "build": "npx tsc --noEmit && rollup -c rollup.config.js && npm run make-package-jsons", "clean": "rimraf dist", "lint": "npx eslint . --ext .ts", "lint:fix": "yarn run lint -- --fix", diff --git a/packages/shared/sdk-client/rollup.config.js b/packages/shared/sdk-client/rollup.config.js index 3d1e3bd4a1..81b9cde6ec 100644 --- a/packages/shared/sdk-client/rollup.config.js +++ b/packages/shared/sdk-client/rollup.config.js @@ -21,7 +21,7 @@ const getSharedConfig = (format, file) => ({ export default [ { - ...getSharedConfig('es', 'dist/index.mjs'), + ...getSharedConfig('es', 'dist/esm/index.mjs'), plugins: [ typescript({ module: 'esnext', @@ -37,7 +37,7 @@ export default [ ], }, { - ...getSharedConfig('cjs', 'dist/index.cjs'), - plugins: [typescript({ tsconfig: './tsconfig.json' }), common(), resolve(), json()], + ...getSharedConfig('cjs', 'dist/cjs/index.cjs'), + plugins: [typescript({ tsconfig: './tsconfig.json', outputToFilesystem: true, }), common(), resolve(), json()], }, ];