From 66eb7fd01b7620f2ed07aa68a5af714e6ea49116 Mon Sep 17 00:00:00 2001 From: Anton Kosyakov Date: Tue, 19 Sep 2023 19:55:10 +0000 Subject: [PATCH] [public-api] export ESM modules --- components/public-api/typescript/package.json | 26 ++++++++++++++++--- .../public-api/typescript/tsconfig.json | 3 ++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/components/public-api/typescript/package.json b/components/public-api/typescript/package.json index b296bc2f61a54e..10930d60776972 100644 --- a/components/public-api/typescript/package.json +++ b/components/public-api/typescript/package.json @@ -4,11 +4,31 @@ "license": "AGPL-3.0", "main": "./lib/index.js", "types": "./lib/index.d.ts", + "module": "./lib/esm/index.js", "files": [ "lib" ], + "exports": { + ".": { + "types": "./lib/index.d.ts", + "import": "./lib/esm/index.js", + "require": "./lib/index.js" + }, + "./lib/*": { + "types": "./lib/*.d.ts", + "import": "./lib/esm/*.js", + "require": "./lib/*.js" + }, + "./lib/gitpod/experimental/v1": { + "types": "./lib/gitpod/experimental/v1/index.d.ts", + "import": "./lib/esm/gitpod/experimental/v1/index.js", + "require": "./lib/gitpod/experimental/v1/index.js" + } + }, "scripts": { - "build": "mkdir -p lib; tsc", + "build": "yarn run build:cjs && yarn run build:esm", + "build:cjs": "tsc", + "build:esm": "tsc --module es2015 --outDir ./lib/esm", "watch": "leeway exec --package .:lib --transitive-dependencies --filter-type yarn --components --parallel -- tsc -w --preserveWatchOutput", "test": "mocha --opts mocha.opts './**/*.spec.ts' --exclude './node_modules/**'", "test:brk": "yarn test --inspect-brk" @@ -16,11 +36,11 @@ "dependencies": { "@bufbuild/connect": "^0.13.0", "@bufbuild/protobuf": "^0.1.1", - "@bufbuild/protoc-gen-connect-web": "^0.2.1", - "@bufbuild/protoc-gen-es": "^0.1.1", "prom-client": "^14.2.0" }, "devDependencies": { + "@bufbuild/protoc-gen-connect-web": "^0.2.1", + "@bufbuild/protoc-gen-es": "^0.1.1", "@testdeck/mocha": "0.1.2", "@types/chai": "^4.1.2", "@types/node": "^16.11.0", diff --git a/components/public-api/typescript/tsconfig.json b/components/public-api/typescript/tsconfig.json index 7776e237510d1a..847b7b462c489b 100644 --- a/components/public-api/typescript/tsconfig.json +++ b/components/public-api/typescript/tsconfig.json @@ -3,6 +3,7 @@ "rootDir": "src", "experimentalDecorators": true, "outDir": "lib", + "declarationDir": "lib", "lib": [ "es6", "esnext.asynciterable", @@ -14,7 +15,7 @@ "emitDecoratorMetadata": true, "strictPropertyInitialization": false, "downlevelIteration": true, - "module": "ES6", + "module": "CommonJS", "moduleResolution": "node", "target": "es6", "jsx": "react",