diff --git a/package-lock.json b/package-lock.json index 418b98173..e989647b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "connect-web", + "name": "connect-es", "lockfileVersion": 3, "requires": true, "packages": { @@ -968,16 +968,16 @@ } }, "node_modules/@bufbuild/protobuf": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-1.3.2.tgz", - "integrity": "sha512-Hw8ZzJEaT3JkMqeWCUfTJwB6H05b8q/xsw2k/BsXBiUCaTpDKd3pxXR3Vss2R1b+OEzRHXDeiO35M0BvVk2Sgg==" + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-1.3.3.tgz", + "integrity": "sha512-AoHSiIpTFF97SQgmQni4c+Tyr0CDhkaRaR2qGEJTEbauqQwLRpLrd9yVv//wVHOSxr/b4FJcL54VchhY6710xA==" }, "node_modules/@bufbuild/protoc-gen-es": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@bufbuild/protoc-gen-es/-/protoc-gen-es-1.3.2.tgz", - "integrity": "sha512-m/vMlbX4CQ24vJ1LEhrYW4pF04Psvox4cejcjiuGM121CHgpMdkd2tEOEY9xggvjbMsTNF+ZoIhfxIWBRKnh2Q==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@bufbuild/protoc-gen-es/-/protoc-gen-es-1.3.3.tgz", + "integrity": "sha512-waqpvdFyqcrrmoAW9c8VCtDmT4+NYDQg/W8DAsMC2/+rXKGQYy3YbxobOuwVm3g/MJC1Gvv6ON/arxq4gYHXYw==", "dependencies": { - "@bufbuild/protoplugin": "1.3.2" + "@bufbuild/protoplugin": "1.3.3" }, "bin": { "protoc-gen-es": "bin/protoc-gen-es" @@ -986,7 +986,7 @@ "node": ">=14" }, "peerDependencies": { - "@bufbuild/protobuf": "1.3.2" + "@bufbuild/protobuf": "1.3.3" }, "peerDependenciesMeta": { "@bufbuild/protobuf": { @@ -995,11 +995,11 @@ } }, "node_modules/@bufbuild/protoplugin": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@bufbuild/protoplugin/-/protoplugin-1.3.2.tgz", - "integrity": "sha512-d6YWD1nKaH5jA0tPY0mfdAcg5rCqCeVw7zLfReMIS8WW/aYtShPwmWS71XpTFMP0LQWlbUiTyYjvNGR35a4hWQ==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@bufbuild/protoplugin/-/protoplugin-1.3.3.tgz", + "integrity": "sha512-sxalYoj+fWxUakknePKfqRpcGlxz45Gcjpth2M274ZvQN+XKwMLVLevArsZWFzGcPoAkiDWMFHhfeQXfjsu+uA==", "dependencies": { - "@bufbuild/protobuf": "1.3.2", + "@bufbuild/protobuf": "1.3.3", "@typescript/vfs": "^1.4.0", "typescript": "4.5.2" } @@ -3357,9 +3357,9 @@ } }, "node_modules/engine.io": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.5.2.tgz", - "integrity": "sha512-IXsMcGpw/xRfjra46sVZVHiSWo/nJ/3g1337q9KNXtS6YRzbW5yIzTCb9DjhrBe7r3GZQR0I4+nq+4ODk5g/cA==", + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.5.3.tgz", + "integrity": "sha512-IML/R4eG/pUS5w7OfcDE0jKrljWS9nwnEfsxWCIJF5eO6AHo6+Hlv+lQbdlAYsiJPHzUthLm1RUjnBzWOs45cw==", "dependencies": { "@types/cookie": "^0.4.1", "@types/cors": "^2.8.12", @@ -7107,9 +7107,9 @@ } }, "node_modules/sonic-boom": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-3.6.0.tgz", - "integrity": "sha512-5Rs7m4IO/mW1WHouC6q6PGJsXO6hSAduwB3ltTsKaDU0Bd7sc5QEUK/jF0YL583g3BG7QV0Dg0rQNZrwZhY6Xg==", + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-3.6.1.tgz", + "integrity": "sha512-QV+p5nXPiUiSMxn/k5bOL+hzCpafdj1voL+hywPZhheRSYyYp7CF15rNdz1evOXCUn/tFb7R62PDX1yJmtoTgg==", "dependencies": { "atomic-sleep": "^1.0.0" } @@ -8378,13 +8378,13 @@ "version": "1.1.1", "license": "Apache-2.0", "devDependencies": { - "@bufbuild/protoc-gen-es": "^1.3.1", + "@bufbuild/protoc-gen-es": "^1.3.3", "@types/jasmine": "^4.3.5", "jasmine": "^5.0.0", "undici": "^5.25.4" }, "peerDependencies": { - "@bufbuild/protobuf": "^1.2.1" + "@bufbuild/protobuf": "^1.3.3" } }, "packages/connect-express": { @@ -8398,7 +8398,7 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@bufbuild/protobuf": "^1.2.1", + "@bufbuild/protobuf": "^1.3.3", "@connectrpc/connect": "1.1.1", "@connectrpc/connect-node": "1.1.1" } @@ -8411,7 +8411,7 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@bufbuild/protobuf": "^1.2.1", + "@bufbuild/protobuf": "^1.3.3", "@connectrpc/connect": "1.1.1", "@connectrpc/connect-node": "1.1.1", "fastify": "^4.22.1" @@ -8444,7 +8444,7 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@bufbuild/protobuf": "^1.2.1", + "@bufbuild/protobuf": "^1.3.3", "@connectrpc/connect": "1.1.1", "@connectrpc/connect-node": "1.1.1", "next": "^13.2.4" @@ -8465,7 +8465,7 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@bufbuild/protobuf": "^1.2.1", + "@bufbuild/protobuf": "^1.3.3", "@connectrpc/connect": "1.1.1" } }, @@ -8491,14 +8491,14 @@ "version": "1.1.1", "license": "Apache-2.0", "peerDependencies": { - "@bufbuild/protobuf": "^1.2.1", + "@bufbuild/protobuf": "^1.3.3", "@connectrpc/connect": "1.1.1" } }, "packages/connect-web-bench": { "name": "@connectrpc/connect-web-bench", "dependencies": { - "@bufbuild/protobuf": "^1.3.1", + "@bufbuild/protobuf": "^1.3.3", "@bufbuild/protoc-gen-es": "^1.3.1", "@connectrpc/connect-web": "1.1.1", "brotli": "^1.3.3", @@ -8525,7 +8525,7 @@ "packages/example": { "name": "@connectrpc/example", "dependencies": { - "@bufbuild/protobuf": "^1.3.1", + "@bufbuild/protobuf": "^1.3.3", "@connectrpc/connect-node": "^1.1.1", "@connectrpc/connect-web": "^1.1.1", "tsx": "^3.13.0" @@ -8547,8 +8547,8 @@ "version": "1.1.1", "license": "Apache-2.0", "dependencies": { - "@bufbuild/protobuf": "^1.3.1", - "@bufbuild/protoplugin": "^1.3.1" + "@bufbuild/protobuf": "^1.3.3", + "@bufbuild/protoplugin": "^1.3.3" }, "bin": { "protoc-gen-connect-es": "bin/protoc-gen-connect-es" @@ -8557,7 +8557,7 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@bufbuild/protoc-gen-es": "^1.2.1", + "@bufbuild/protoc-gen-es": "^1.3.3", "@connectrpc/connect": "1.1.1" }, "peerDependenciesMeta": { diff --git a/packages/connect-express/package.json b/packages/connect-express/package.json index 3df648e06..b15516a5f 100644 --- a/packages/connect-express/package.json +++ b/packages/connect-express/package.json @@ -7,26 +7,22 @@ "url": "https://github.com/connectrpc/connect-es.git", "directory": "packages/connect-express" }, - "sideEffects": false, "scripts": { - "clean": "rm -rf ./dist/cjs/* ./dist/esm/*", - "build": "npm run build:cjs && npm run build:esm", + "clean": "rm -rf ./dist/*", + "build": "npm run build:cjs && npm run build:esm && npm run build:proxy", "build:cjs": "tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs --declaration --declarationDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'", "build:esm": "tsc --project tsconfig.json --module ES2015 --verbatimModuleSyntax --outDir ./dist/esm --declaration --declarationDir ./dist/esm", + "build:proxy": "node ../../scripts/gen-esm-proxy.mjs .", "attw": "attw --pack" }, - "main": "./dist/cjs/index.js", "type": "module", + "sideEffects": false, + "main": "./dist/cjs/index.js", "exports": { ".": { - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - }, - "require": { - "types": "./dist/cjs/index.d.ts", - "default": "./dist/cjs/index.js" - } + "module": "./dist/esm/index.js", + "require": "./dist/cjs/index.js", + "import": "./dist/proxy/index.js" } }, "engines": { @@ -36,7 +32,7 @@ "@types/express": "^4.17.18" }, "peerDependencies": { - "@bufbuild/protobuf": "^1.2.1", + "@bufbuild/protobuf": "^1.3.3", "@connectrpc/connect": "1.1.1", "@connectrpc/connect-node": "1.1.1" }, diff --git a/packages/connect-fastify/package.json b/packages/connect-fastify/package.json index ad03db205..b3c1ade79 100644 --- a/packages/connect-fastify/package.json +++ b/packages/connect-fastify/package.json @@ -7,33 +7,29 @@ "url": "https://github.com/connectrpc/connect-es.git", "directory": "packages/connect-fastify" }, - "sideEffects": false, "scripts": { - "clean": "rm -rf ./dist/cjs/* ./dist/esm/*", - "build": "npm run build:cjs && npm run build:esm", + "clean": "rm -rf ./dist/*", + "build": "npm run build:cjs && npm run build:esm && npm run build:proxy", "build:cjs": "tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs --declaration --declarationDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'", "build:esm": "tsc --project tsconfig.json --module ES2015 --verbatimModuleSyntax --outDir ./dist/esm --declaration --declarationDir ./dist/esm", + "build:proxy": "node ../../scripts/gen-esm-proxy.mjs .", "attw": "attw --pack" }, - "main": "./dist/cjs/index.js", "type": "module", + "sideEffects": false, + "main": "./dist/cjs/index.js", "exports": { ".": { - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - }, - "require": { - "types": "./dist/cjs/index.d.ts", - "default": "./dist/cjs/index.js" - } + "module": "./dist/esm/index.js", + "require": "./dist/cjs/index.js", + "import": "./dist/proxy/index.js" } }, "engines": { "node": ">=16.0.0" }, "peerDependencies": { - "@bufbuild/protobuf": "^1.2.1", + "@bufbuild/protobuf": "^1.3.3", "fastify": "^4.22.1", "@connectrpc/connect": "1.1.1", "@connectrpc/connect-node": "1.1.1" diff --git a/packages/connect-next/package.json b/packages/connect-next/package.json index 2d6aa7cd8..a432dde51 100644 --- a/packages/connect-next/package.json +++ b/packages/connect-next/package.json @@ -7,33 +7,29 @@ "url": "https://github.com/connectrpc/connect-es.git", "directory": "packages/connect-next" }, - "sideEffects": false, "scripts": { - "clean": "rm -rf ./dist/cjs/* ./dist/esm/*", - "build": "npm run build:cjs && npm run build:esm", + "clean": "rm -rf ./dist/*", + "build": "npm run build:cjs && npm run build:esm && npm run build:proxy", "build:cjs": "tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs --declaration --declarationDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'", "build:esm": "tsc --project tsconfig.json --module ES2015 --verbatimModuleSyntax --outDir ./dist/esm --declaration --declarationDir ./dist/esm", + "build:proxy": "node ../../scripts/gen-esm-proxy.mjs .", "attw": "attw --pack" }, - "main": "./dist/cjs/index.js", "type": "module", + "sideEffects": false, + "main": "./dist/cjs/index.js", "exports": { ".": { - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - }, - "require": { - "types": "./dist/cjs/index.d.ts", - "default": "./dist/cjs/index.js" - } + "module": "./dist/esm/index.js", + "require": "./dist/cjs/index.js", + "import": "./dist/proxy/index.js" } }, "engines": { "node": ">=16.0.0" }, "peerDependencies": { - "@bufbuild/protobuf": "^1.2.1", + "@bufbuild/protobuf": "^1.3.3", "next": "^13.2.4", "@connectrpc/connect": "1.1.1", "@connectrpc/connect-node": "1.1.1" diff --git a/packages/connect-node-test/src/gen/connectrpc/conformance/v1/messages_pb.ts b/packages/connect-node-test/src/gen/connectrpc/conformance/v1/messages_pb.ts index 07f5f0749..7279b05cd 100644 --- a/packages/connect-node-test/src/gen/connectrpc/conformance/v1/messages_pb.ts +++ b/packages/connect-node-test/src/gen/connectrpc/conformance/v1/messages_pb.ts @@ -30,7 +30,7 @@ // Message definitions to be used by integration test service definitions. -// @generated by protoc-gen-es v1.3.2 with parameter "ts_nocheck=false,target=ts" +// @generated by protoc-gen-es v1.3.3 with parameter "ts_nocheck=false,target=ts" // @generated from file connectrpc/conformance/v1/messages.proto (package connectrpc.conformance.v1, syntax proto3) /* eslint-disable */ diff --git a/packages/connect-node-test/src/gen/server/v1/server_pb.ts b/packages/connect-node-test/src/gen/server/v1/server_pb.ts index ac4d0a788..00128aada 100644 --- a/packages/connect-node-test/src/gen/server/v1/server_pb.ts +++ b/packages/connect-node-test/src/gen/server/v1/server_pb.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// @generated by protoc-gen-es v1.3.2 with parameter "ts_nocheck=false,target=ts" +// @generated by protoc-gen-es v1.3.3 with parameter "ts_nocheck=false,target=ts" // @generated from file server/v1/server.proto (package server.v1, syntax proto3) /* eslint-disable */ diff --git a/packages/connect-node/package.json b/packages/connect-node/package.json index 31a57fcca..a6010c863 100644 --- a/packages/connect-node/package.json +++ b/packages/connect-node/package.json @@ -8,25 +8,21 @@ "directory": "packages/connect-node" }, "scripts": { - "clean": "rm -rf ./dist/cjs/* ./dist/esm/*", - "build": "npm run build:cjs && npm run build:esm", + "clean": "rm -rf ./dist/*", + "build": "npm run build:cjs && npm run build:esm && npm run build:proxy", "build:cjs": "tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs --declaration --declarationDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'", "build:esm": "tsc --project tsconfig.json --module ES2015 --verbatimModuleSyntax --outDir ./dist/esm --declaration --declarationDir ./dist/esm", - "jasmine": "jasmine --config=jasmine.json", - "attw": "attw --pack" + "build:proxy": "node ../../scripts/gen-esm-proxy.mjs .", + "attw": "attw --pack", + "jasmine": "jasmine --config=jasmine.json" }, - "main": "./dist/cjs/index.js", "type": "module", + "main": "./dist/cjs/index.js", "exports": { ".": { - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - }, - "require": { - "types": "./dist/cjs/index.d.ts", - "default": "./dist/cjs/index.js" - } + "module": "./dist/esm/index.js", + "require": "./dist/cjs/index.js", + "import": "./dist/proxy/index.js" } }, "engines": { @@ -36,7 +32,7 @@ "undici": "^5.25.4" }, "peerDependencies": { - "@bufbuild/protobuf": "^1.2.1", + "@bufbuild/protobuf": "^1.3.3", "@connectrpc/connect": "1.1.1" }, "devDependencies": { diff --git a/packages/connect-web-bench/package.json b/packages/connect-web-bench/package.json index 7e5178d70..43a0f5902 100644 --- a/packages/connect-web-bench/package.json +++ b/packages/connect-web-bench/package.json @@ -8,7 +8,7 @@ }, "dependencies": { "@connectrpc/connect-web": "1.1.1", - "@bufbuild/protobuf": "^1.3.1", + "@bufbuild/protobuf": "^1.3.3", "@bufbuild/protoc-gen-es": "^1.3.1", "brotli": "^1.3.3", "esbuild": "^0.16.12", diff --git a/packages/connect-web-bench/src/gen/connectweb/connectrpc/eliza/v1/eliza_pb.ts b/packages/connect-web-bench/src/gen/connectweb/connectrpc/eliza/v1/eliza_pb.ts index f4dd1d9da..b46b4876c 100644 --- a/packages/connect-web-bench/src/gen/connectweb/connectrpc/eliza/v1/eliza_pb.ts +++ b/packages/connect-web-bench/src/gen/connectweb/connectrpc/eliza/v1/eliza_pb.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// @generated by protoc-gen-es v1.3.2 with parameter "ts_nocheck=false,target=ts" +// @generated by protoc-gen-es v1.3.3 with parameter "ts_nocheck=false,target=ts" // @generated from file connectrpc/eliza/v1/eliza.proto (package connectrpc.eliza.v1, syntax proto3) /* eslint-disable */ diff --git a/packages/connect-web-test/src/gen/connectrpc/conformance/v1/messages_pb.ts b/packages/connect-web-test/src/gen/connectrpc/conformance/v1/messages_pb.ts index 07f5f0749..7279b05cd 100644 --- a/packages/connect-web-test/src/gen/connectrpc/conformance/v1/messages_pb.ts +++ b/packages/connect-web-test/src/gen/connectrpc/conformance/v1/messages_pb.ts @@ -30,7 +30,7 @@ // Message definitions to be used by integration test service definitions. -// @generated by protoc-gen-es v1.3.2 with parameter "ts_nocheck=false,target=ts" +// @generated by protoc-gen-es v1.3.3 with parameter "ts_nocheck=false,target=ts" // @generated from file connectrpc/conformance/v1/messages.proto (package connectrpc.conformance.v1, syntax proto3) /* eslint-disable */ diff --git a/packages/connect-web-test/src/gen/connectrpc/eliza/v1/eliza_pb.ts b/packages/connect-web-test/src/gen/connectrpc/eliza/v1/eliza_pb.ts index f4dd1d9da..b46b4876c 100644 --- a/packages/connect-web-test/src/gen/connectrpc/eliza/v1/eliza_pb.ts +++ b/packages/connect-web-test/src/gen/connectrpc/eliza/v1/eliza_pb.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// @generated by protoc-gen-es v1.3.2 with parameter "ts_nocheck=false,target=ts" +// @generated by protoc-gen-es v1.3.3 with parameter "ts_nocheck=false,target=ts" // @generated from file connectrpc/eliza/v1/eliza.proto (package connectrpc.eliza.v1, syntax proto3) /* eslint-disable */ diff --git a/packages/connect-web-test/src/gen/server/v1/server_pb.ts b/packages/connect-web-test/src/gen/server/v1/server_pb.ts index ac4d0a788..00128aada 100644 --- a/packages/connect-web-test/src/gen/server/v1/server_pb.ts +++ b/packages/connect-web-test/src/gen/server/v1/server_pb.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// @generated by protoc-gen-es v1.3.2 with parameter "ts_nocheck=false,target=ts" +// @generated by protoc-gen-es v1.3.3 with parameter "ts_nocheck=false,target=ts" // @generated from file server/v1/server.proto (package server.v1, syntax proto3) /* eslint-disable */ diff --git a/packages/connect-web/package.json b/packages/connect-web/package.json index b72c58f35..0c988b4ca 100644 --- a/packages/connect-web/package.json +++ b/packages/connect-web/package.json @@ -7,30 +7,26 @@ "url": "https://github.com/connectrpc/connect-es.git", "directory": "packages/connect-web" }, - "sideEffects": false, "scripts": { - "clean": "rm -rf ./dist/cjs/* ./dist/esm/*", - "build": "npm run build:cjs && npm run build:esm", + "clean": "rm -rf ./dist/*", + "build": "npm run build:cjs && npm run build:esm && npm run build:proxy", "build:cjs": "tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs --declaration --declarationDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'", "build:esm": "tsc --project tsconfig.json --module ES2015 --verbatimModuleSyntax --outDir ./dist/esm --declaration --declarationDir ./dist/esm", + "build:proxy": "node ../../scripts/gen-esm-proxy.mjs .", "attw": "attw --pack" }, - "main": "./dist/cjs/index.js", "type": "module", + "sideEffects": false, + "main": "./dist/cjs/index.js", "exports": { ".": { - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - }, - "require": { - "types": "./dist/cjs/index.d.ts", - "default": "./dist/cjs/index.js" - } + "module": "./dist/esm/index.js", + "require": "./dist/cjs/index.js", + "import": "./dist/proxy/index.js" } }, "peerDependencies": { - "@bufbuild/protobuf": "^1.2.1", + "@bufbuild/protobuf": "^1.3.3", "@connectrpc/connect": "1.1.1" }, "files": [ diff --git a/packages/connect/.npmignore b/packages/connect/.npmignore index 44d9961d5..95869e1c7 100644 --- a/packages/connect/.npmignore +++ b/packages/connect/.npmignore @@ -3,3 +3,4 @@ /dist/*/**/*.spec.js /dist/*/**/*.spec.d.ts /buf.gen.yaml +/scripts/update-user-agent.mjs diff --git a/packages/connect/package.json b/packages/connect/package.json index 1152e7cea..de12b30f8 100644 --- a/packages/connect/package.json +++ b/packages/connect/package.json @@ -8,67 +8,44 @@ "url": "https://github.com/connectrpc/connect-es.git", "directory": "packages/connect" }, - "sideEffects": false, "scripts": { - "clean": "rm -rf ./dist/cjs/* ./dist/esm/*", + "clean": "rm -rf ./dist/*", "generate": "buf generate src/protocol-grpc/proto", - "build": "npm run build:cjs && npm run build:esm && node scripts/update-user-agent.mjs", + "build": "npm run build:cjs && npm run build:esm && npm run build:proxy && node scripts/update-user-agent.mjs", "build:cjs": "tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs --declaration --declarationDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'", - "build:esm": "tsc --project tsconfig.json --module ES2015 --verbatimModuleSyntax --outDir ./dist/esm --declaration --declarationDir ./dist/esm && echo >./dist/esm/package.json '{\"type\":\"module\", \"sideEffects\":false}'", + "build:esm": "tsc --project tsconfig.json --module ES2015 --verbatimModuleSyntax --outDir ./dist/esm --declaration --declarationDir ./dist/esm", + "build:proxy": "node ../../scripts/gen-esm-proxy.mjs . protocol protocol-connect protocol-grpc protocol-grpc-web", "jasmine": "jasmine --config=jasmine.json", "attw": "attw --pack" }, + "type": "module", + "sideEffects": false, "main": "./dist/cjs/index.js", "exports": { ".": { - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - }, - "require": { - "types": "./dist/cjs/index.d.ts", - "default": "./dist/cjs/index.js" - } + "module": "./dist/esm/index.js", + "require": "./dist/cjs/index.js", + "import": "./dist/proxy/index.js" }, "./protocol": { - "import": { - "types": "./dist/esm/protocol/index.d.ts", - "default": "./dist/esm/protocol/index.js" - }, - "require": { - "types": "./dist/cjs/protocol/index.d.ts", - "default": "./dist/cjs/protocol/index.js" - } + "module": "./dist/esm/protocol/index.js", + "require": "./dist/cjs/protocol/index.js", + "import": "./dist/proxy/protocol/index.js" }, "./protocol-connect": { - "import": { - "types": "./dist/esm/protocol-connect/index.d.ts", - "default": "./dist/esm/protocol-connect/index.js" - }, - "require": { - "types": "./dist/cjs/protocol-connect/index.d.ts", - "default": "./dist/cjs/protocol-connect/index.js" - } + "module": "./dist/esm/protocol-connect/index.js", + "require": "./dist/cjs/protocol-connect/index.js", + "import": "./dist/proxy/protocol-connect/index.js" }, "./protocol-grpc": { - "import": { - "types": "./dist/esm/protocol-grpc/index.d.ts", - "default": "./dist/esm/protocol-grpc/index.js" - }, - "require": { - "types": "./dist/cjs/protocol-grpc/index.d.ts", - "default": "./dist/cjs/protocol-grpc/index.js" - } + "module": "./dist/esm/protocol-grpc/index.js", + "require": "./dist/cjs/protocol-grpc/index.js", + "import": "./dist/proxy/protocol-grpc/index.js" }, "./protocol-grpc-web": { - "import": { - "types": "./dist/esm/protocol-grpc-web/index.d.ts", - "default": "./dist/esm/protocol-grpc-web/index.js" - }, - "require": { - "types": "./dist/cjs/protocol-grpc-web/index.d.ts", - "default": "./dist/cjs/protocol-grpc-web/index.js" - } + "module": "./dist/esm/protocol-grpc-web/index.js", + "require": "./dist/cjs/protocol-grpc-web/index.js", + "import": "./dist/proxy/protocol-grpc-web/index.js" } }, "typesVersions": { @@ -88,10 +65,10 @@ } }, "peerDependencies": { - "@bufbuild/protobuf": "^1.2.1" + "@bufbuild/protobuf": "^1.3.3" }, "devDependencies": { - "@bufbuild/protoc-gen-es": "^1.3.1", + "@bufbuild/protoc-gen-es": "^1.3.3", "@types/jasmine": "^4.3.5", "jasmine": "^5.0.0", "undici": "^5.25.4" diff --git a/packages/connect/src/protocol-grpc/gen/status_pb.ts b/packages/connect/src/protocol-grpc/gen/status_pb.ts index f16339cc4..0063b5698 100644 --- a/packages/connect/src/protocol-grpc/gen/status_pb.ts +++ b/packages/connect/src/protocol-grpc/gen/status_pb.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// @generated by protoc-gen-es v1.3.2 with parameter "target=ts" +// @generated by protoc-gen-es v1.3.3 with parameter "target=ts" // @generated from file status.proto (package google.rpc, syntax proto3) /* eslint-disable */ // @ts-nocheck diff --git a/packages/example/package.json b/packages/example/package.json index 5943009c3..ecf95948e 100644 --- a/packages/example/package.json +++ b/packages/example/package.json @@ -14,7 +14,7 @@ "dependencies": { "@connectrpc/connect-node": "^1.1.1", "@connectrpc/connect-web": "^1.1.1", - "@bufbuild/protobuf": "^1.3.1", + "@bufbuild/protobuf": "^1.3.3", "tsx": "^3.13.0" }, "devDependencies": { diff --git a/packages/example/src/gen/eliza_pb.ts b/packages/example/src/gen/eliza_pb.ts index b6a75e226..7c3b2ed21 100644 --- a/packages/example/src/gen/eliza_pb.ts +++ b/packages/example/src/gen/eliza_pb.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// @generated by protoc-gen-es v1.3.2 with parameter "target=ts" +// @generated by protoc-gen-es v1.3.3 with parameter "target=ts" // @generated from file eliza.proto (package connectrpc.eliza.v1, syntax proto3) /* eslint-disable */ // @ts-nocheck diff --git a/packages/protoc-gen-connect-es/package.json b/packages/protoc-gen-connect-es/package.json index 3edbd2bd4..c1af7a56a 100644 --- a/packages/protoc-gen-connect-es/package.json +++ b/packages/protoc-gen-connect-es/package.json @@ -20,12 +20,12 @@ }, "preferUnplugged": true, "dependencies": { - "@bufbuild/protobuf": "^1.3.1", - "@bufbuild/protoplugin": "^1.3.1" + "@bufbuild/protobuf": "^1.3.3", + "@bufbuild/protoplugin": "^1.3.3" }, "peerDependencies": { "@connectrpc/connect": "1.1.1", - "@bufbuild/protoc-gen-es": "^1.2.1" + "@bufbuild/protoc-gen-es": "^1.3.3" }, "peerDependenciesMeta": { "@connectrpc/connect": { diff --git a/scripts/gen-esm-proxy.mjs b/scripts/gen-esm-proxy.mjs new file mode 100644 index 000000000..4aed56c3d --- /dev/null +++ b/scripts/gen-esm-proxy.mjs @@ -0,0 +1,101 @@ +import {existsSync, mkdirSync, readFileSync, writeFileSync} from "node:fs"; +import * as path from "node:path"; +import {exit, stderr, stdout, argv} from "node:process"; + +const args = argv.slice(2); + +if (args.length === 0) { + stdout.write(`USAGE: ${path.basename(argv[1])} [...path] +path: One or more subpath exports. A dot (.) is valid. + +Generates ESM wrappers for dual packages. + +Example: + + ${path.basename(argv[1])} . foo + +Assumes that the following CJS artifacts exist: + + dist/cjs + ├── index.d.ts + ├── index.js + └── foo + ├── index.d.ts + └── index.js + +Generates the following ESM wrappers: + + dist/proxy + ├── index.d.ts + ├── index.js + └── foo + ├── index.d.ts + └── index.js + +package.json must contain: + + "type": "module", + "exports": { + ".": { + "require": "./dist/cjs/index.js", + "import": "./dist/proxy/index.js" + }, + "./protocol": { + "require": "./dist/cjs/foo/index.js", + "import": "./dist/proxy/foo/index.js" + }, + +Known limitations: +- expects CJS files with a .js extension, not .cjs +- does not support default exports +- supports only simple subpath directory exports, assuming a index.js file +- does not support export patterns +`); + exit(1); +} + +const cjsDist = "dist/cjs"; +const proxyDist = "dist/proxy"; + +const packageType = readPackageJsonType(); +if (packageType !== "module") { + stderr.write(`package.json is missing "type": "module" field.\n`); + exit(1); +} + +for (const subpath of args) { + const cjsPath = path.join(cjsDist, subpath, "index.js"); + if (!existsSync(cjsPath)) { + stderr.write(`CommonJS artifact for subpath "${subpath}" not found at expected path ${cjsPath}\n`); + exit(1); + } + const proxyDir = path.join(proxyDist, subpath); + if (!existsSync(proxyDir)) { + mkdirSync(proxyDir, { recursive: true }); + } + const cjsImportPath = path.relative(proxyDir, cjsPath) + writeFileSync( + path.join(proxyDir, "index.js"), + `export * from "${cjsImportPath}";\n`, + ); + writeFileSync( + path.join(proxyDir, "index.d.ts"), + `export * from "${cjsImportPath}";\n`, + ); +} + +/** + * @return {"commonjs"|"module"} + */ +function readPackageJsonType() { + const pkgString = readFileSync("package.json", "utf-8"); + const pkg = JSON.parse(pkgString); + const t = pkg.type; + if (typeof t !== "string") { + return "commonjs"; + } + if (t.toLowerCase() === "module") { + return "module"; + } + return "commonjs"; +}