diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8484116..528aa24 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,7 +9,14 @@ on: jobs: ci: runs-on: ubuntu-20.04 + strategy: + matrix: + node-version: [18, 20] steps: + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + - name: checkout uses: actions/checkout@v4 diff --git a/package-lock.json b/package-lock.json index 090330f..c9ffef0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ }, "devDependencies": { "@bufbuild/license-header": "^0.0.4", - "@bufbuild/protobuf": "^1.6.0", + "@bufbuild/protobuf": "^1.7.0", "@typescript-eslint/eslint-plugin": "^6.17.0", "@typescript-eslint/parser": "^6.17.0", "eslint": "^8.56.0", @@ -139,16 +139,18 @@ } }, "node_modules/@bufbuild/protobuf": { - "version": "1.6.0", - "license": "(Apache-2.0 AND BSD-3-Clause)" + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-1.7.0.tgz", + "integrity": "sha512-jIsRadRsyxf6ERBU1auY2c1k3doFdqh15F4HRZs4BELVuBtpN+3ipkXqcsWE+rD+EQNigeR29SfQ+ES6UX/jGg==" }, "node_modules/@bufbuild/protoc-gen-es": { - "version": "1.6.0", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@bufbuild/protoc-gen-es/-/protoc-gen-es-1.7.0.tgz", + "integrity": "sha512-b9LwP8p+9ywtCM1P1pqQBrJF4RPyWbzhM8mTHvLEtHglogso70kmDmoIcqJ+kS/+65Bc7ilHFVGJF95GceLy1Q==", "dev": true, - "license": "Apache-2.0", "dependencies": { - "@bufbuild/protobuf": "^1.6.0", - "@bufbuild/protoplugin": "1.6.0" + "@bufbuild/protobuf": "^1.7.0", + "@bufbuild/protoplugin": "1.7.0" }, "bin": { "protoc-gen-es": "bin/protoc-gen-es" @@ -157,7 +159,7 @@ "node": ">=14" }, "peerDependencies": { - "@bufbuild/protobuf": "1.6.0" + "@bufbuild/protobuf": "1.7.0" }, "peerDependenciesMeta": { "@bufbuild/protobuf": { @@ -166,11 +168,12 @@ } }, "node_modules/@bufbuild/protoplugin": { - "version": "1.6.0", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@bufbuild/protoplugin/-/protoplugin-1.7.0.tgz", + "integrity": "sha512-NgiGDjef/yijoVxevLLlIWY7RAqNmBEADMgdJ4VKvvlyNnO6xNslFZx/g+jlY2KW+vKjj+2Fcr3n0fSDDN4Asw==", "dev": true, - "license": "(Apache-2.0 AND BSD-3-Clause)", "dependencies": { - "@bufbuild/protobuf": "1.6.0", + "@bufbuild/protobuf": "1.7.0", "@typescript/vfs": "^1.4.0", "typescript": "4.5.2" } @@ -197,8 +200,9 @@ } }, "node_modules/@connectrpc/connect": { - "version": "1.2.0", - "license": "Apache-2.0", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@connectrpc/connect/-/connect-1.3.0.tgz", + "integrity": "sha512-kTeWxJnLLtxKc2ZSDN0rIBgwfP8RwcLknthX4AKlIAmN9ZC4gGnCbwp+3BKcP/WH5c8zGBAWqSY3zeqCM+ah7w==", "peerDependencies": { "@bufbuild/protobuf": "^1.4.2" } @@ -208,19 +212,20 @@ "link": true }, "node_modules/@connectrpc/connect-web": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@connectrpc/connect-web/-/connect-web-1.2.0.tgz", - "integrity": "sha512-vjFKTP/AzSnC8JvkGKRgpggZIB0v+Lv7U+/Tb/pRNGZI0WSElhGDXWgIn3xfcSNQWi079m45c5MlikszzIRsYg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@connectrpc/connect-web/-/connect-web-1.3.0.tgz", + "integrity": "sha512-8HSY8x6douX1LcSFsGEUdjs9jwBe9X+LxkCI8hCtH7vKUCZieQqkRWstoApeIJchHYTaQYqwy2ImKnvwyWwruA==", "dev": true, "peerDependencies": { "@bufbuild/protobuf": "^1.4.2", - "@connectrpc/connect": "1.2.0" + "@connectrpc/connect": "1.3.0" } }, "node_modules/@connectrpc/protoc-gen-connect-es": { - "version": "1.2.0", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@connectrpc/protoc-gen-connect-es/-/protoc-gen-connect-es-1.3.0.tgz", + "integrity": "sha512-UbQN48c0zafo5EFSsh3POIJP6ofYiAgKE1aFOZ2Er4W3flUYihydZdM6TQauPkn7jDj4w9jjLSTTZ9//ecUbPA==", "dev": true, - "license": "Apache-2.0", "dependencies": { "@bufbuild/protobuf": "^1.6.0", "@bufbuild/protoplugin": "^1.6.0" @@ -233,7 +238,7 @@ }, "peerDependencies": { "@bufbuild/protoc-gen-es": "^1.6.0", - "@connectrpc/connect": "1.2.0" + "@connectrpc/connect": "1.3.0" }, "peerDependenciesMeta": { "@bufbuild/protoc-gen-es": { @@ -3718,7 +3723,7 @@ "@types/node": "^20.10.6" }, "peerDependencies": { - "@connectrpc/connect": "^1.1.2", + "@connectrpc/connect": "^1.3.0", "@playwright/test": "^1.0.0" } }, @@ -3733,11 +3738,11 @@ }, "devDependencies": { "@bufbuild/buf": "^1.28.1", - "@bufbuild/protobuf": "^1.6.0", - "@bufbuild/protoc-gen-es": "^1.6.0", - "@connectrpc/connect": "^1.2.0", - "@connectrpc/connect-web": "^1.2.0", - "@connectrpc/protoc-gen-connect-es": "^1.2.0", + "@bufbuild/protobuf": "^1.7.0", + "@bufbuild/protoc-gen-es": "^1.7.0", + "@connectrpc/connect": "^1.3.0", + "@connectrpc/connect-web": "^1.3.0", + "@connectrpc/protoc-gen-connect-es": "^1.3.0", "@types/react": "^18.2.46", "@types/react-dom": "^18.2.18", "esbuild": "^0.19.11", diff --git a/package.json b/package.json index ad6f547..ec969a4 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ }, "devDependencies": { "@bufbuild/license-header": "^0.0.4", - "@bufbuild/protobuf": "^1.6.0", + "@bufbuild/protobuf": "^1.7.0", "@typescript-eslint/eslint-plugin": "^6.17.0", "@typescript-eslint/parser": "^6.17.0", "eslint": "^8.56.0", diff --git a/packages/connect-playwright-example/package.json b/packages/connect-playwright-example/package.json index c120d36..70587cf 100644 --- a/packages/connect-playwright-example/package.json +++ b/packages/connect-playwright-example/package.json @@ -15,11 +15,11 @@ "license": "ISC", "devDependencies": { "@bufbuild/buf": "^1.28.1", - "@bufbuild/protobuf": "^1.6.0", - "@bufbuild/protoc-gen-es": "^1.6.0", - "@connectrpc/connect": "^1.2.0", - "@connectrpc/connect-web": "^1.2.0", - "@connectrpc/protoc-gen-connect-es": "^1.2.0", + "@bufbuild/protobuf": "^1.7.0", + "@bufbuild/protoc-gen-es": "^1.7.0", + "@connectrpc/connect": "^1.3.0", + "@connectrpc/connect-web": "^1.3.0", + "@connectrpc/protoc-gen-connect-es": "^1.3.0", "@types/react": "^18.2.46", "@types/react-dom": "^18.2.18", "esbuild": "^0.19.11", diff --git a/packages/connect-playwright-example/src/gen/connectrpc/eliza/v1/eliza_connect.ts b/packages/connect-playwright-example/src/gen/connectrpc/eliza/v1/eliza_connect.ts index ab01020..a151f62 100644 --- a/packages/connect-playwright-example/src/gen/connectrpc/eliza/v1/eliza_connect.ts +++ b/packages/connect-playwright-example/src/gen/connectrpc/eliza/v1/eliza_connect.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// @generated by protoc-gen-connect-es v1.2.0 with parameter "target=ts" +// @generated by protoc-gen-connect-es v1.3.0 with parameter "target=ts" // @generated from file connectrpc/eliza/v1/eliza.proto (package connectrpc.eliza.v1, syntax proto3) /* eslint-disable */ // @ts-nocheck diff --git a/packages/connect-playwright-example/src/gen/connectrpc/eliza/v1/eliza_pb.ts b/packages/connect-playwright-example/src/gen/connectrpc/eliza/v1/eliza_pb.ts index 9f3e498..1309be2 100644 --- a/packages/connect-playwright-example/src/gen/connectrpc/eliza/v1/eliza_pb.ts +++ b/packages/connect-playwright-example/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.6.0 with parameter "target=ts" +// @generated by protoc-gen-es v1.7.0 with parameter "target=ts" // @generated from file connectrpc/eliza/v1/eliza.proto (package connectrpc.eliza.v1, syntax proto3) /* eslint-disable */ // @ts-nocheck diff --git a/packages/connect-playwright/package.json b/packages/connect-playwright/package.json index 69a5cf5..4723f10 100644 --- a/packages/connect-playwright/package.json +++ b/packages/connect-playwright/package.json @@ -11,10 +11,9 @@ "scripts": { "clean": "rm -rf ./dist/*", "test": "playwright install chromium && jasmine --config=jasmine.json", - "build": "npm run build:cjs && npm run build:esm && npm run build:proxy", + "build": "npm run build:cjs && npm run build:esm", "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:proxy": "node ../../scripts/gen-esm-proxy.mjs .", "format": "prettier --write --ignore-unknown '.' '!dist'", "lint": "eslint --max-warnings 0 .", "attw": "attw --pack", @@ -25,17 +24,13 @@ "main": "./dist/cjs/index.js", "exports": { ".": { - "node": { - "import": "./dist/proxy/index.js", - "require": "./dist/cjs/index.js" - }, "module": "./dist/esm/index.js", "import": "./dist/esm/index.js", "require": "./dist/cjs/index.js" } }, "peerDependencies": { - "@connectrpc/connect": "^1.1.2", + "@connectrpc/connect": "^1.3.0", "@playwright/test": "^1.0.0" }, "devDependencies": { diff --git a/scripts/gen-esm-proxy.mjs b/scripts/gen-esm-proxy.mjs deleted file mode 100644 index 22470d0..0000000 --- a/scripts/gen-esm-proxy.mjs +++ /dev/null @@ -1,103 +0,0 @@ -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"; -}