From 2483a2fb3ec220ebccf9882bfe0ab59cb4528d42 Mon Sep 17 00:00:00 2001 From: Leo Zurbriggen Date: Tue, 11 Aug 2020 09:56:58 +0200 Subject: [PATCH] build es module --- packages/vue-apollo-composable/package.json | 16 +++++++++++++--- packages/vue-apollo-composable/tsconfig.json | 9 +++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/vue-apollo-composable/package.json b/packages/vue-apollo-composable/package.json index 3218e520..e2e08dcb 100644 --- a/packages/vue-apollo-composable/package.json +++ b/packages/vue-apollo-composable/package.json @@ -21,14 +21,24 @@ "publishConfig": { "access": "public" }, - "main": "dist/index.js", - "types": "dist/index.d.ts", + "type": "module", + "main": "dist/cjs/index.js", + "exports": { + ".": { + "require": "./dist/commonjs/index.js", + "default": "./dist/esm/index.js" + } + }, + "types": "dist/esm/index.d.ts", + "module": "./dist/esm/index.js", "files": [ "dist" ], "scripts": { "dev": "yarn build --watch", - "build": "tsc --outDir dist -d", + "build": "npm run build:esm && npm run build:commonjs", + "build:esm": "tsc -m es2015 -d --lib \"DOM\",\"ES5\",\"es2020.symbol.wellknown\" --outDir dist/esm", + "build:commonjs": "tsc -m commonjs --lib \"DOM\",\"ES5\",\"es2020.symbol.wellknown\" --outDir dist/commonjs", "prepublishOnly": "yarn test && yarn build", "test": "yarn test:types", "test:types": "tsc -p tests/types/" diff --git a/packages/vue-apollo-composable/tsconfig.json b/packages/vue-apollo-composable/tsconfig.json index 3fb6adbc..dbcad9b1 100644 --- a/packages/vue-apollo-composable/tsconfig.json +++ b/packages/vue-apollo-composable/tsconfig.json @@ -3,8 +3,9 @@ "target": "es5", "module": "commonjs", "sourceMap": true, + "outDir": "dist", + "moduleResolution": "node" }, - "include": [ - "src/**/*", - ], -} \ No newline at end of file + "exclude": ["node_modules", "**/node_modules/*"], + "include": ["src/**/*"] +}