pb-to-typescript icon indicating copy to clipboard operation
pb-to-typescript copied to clipboard

Generation of types.d.ts breaks when the types.js is too big

Open ArCiGo opened this issue 11 months ago • 2 comments

protobuf.js version: 6.8.6 and latest one (7.2.6).

I have a shell script I use to generate the type definitions from my proto files. It generates properly the types.js, but when it tries to generate the types.d.ts it doesn't generate a new file.

I suspect that probably the script finishes unexpectedly because of the length of the types.js file (almost 1M of lines of code, and continuously growing) and its size (> 59 Mb).

There are no error logs.

My script looks like this.-

#!/usr/bin/env bash

set -e

rm -rf sample_protobuf_build
mkdir sample_protobuf_build
cp -a abc_protobuf sample_protobuf_build/abc_protobuf
cp -a def_protobuf sample_protobuf_build/def_protobuf

cd sample_protobuf_build

if [[ "$OSTYPE" == "darwin"* ]]; then
  LC_ALL=C bash -c "find ./ -type f -print0 | xargs -0 sed -i '' -E 's/( )\\.?(Core)(\\.|\\;)/\\1Proto\\3/g'"
  LC_ALL=C bash -c "find ./ -type f -print0 | xargs -0 sed -i '' -E 's/\\(\\.?(Core)(\\.|\\;)/\\(Proto\\2/g'"
else
  LC_ALL=C bash -c "find ./ -type f -print0 | xargs -0 sed -i -E 's/( )\\.?(Core)(\\.|\\;)/\\1Proto\\3/g'"
  LC_ALL=C bash -c "find ./ -type f -print0 | xargs -0 sed -i -E 's/\\(\\.?(Core)(\\.|\\;)/\\(Proto\\2/g'"
fi


find ./ -name '*.proto' -print0 | LC_ALL=C sort -z | xargs -0 pbjs -t static-module -w commonjs --force-message -o ../dist/types.js
cat ../dist/types.js | pbts -o ../dist/types.d.ts -

Are there any ways to force the command to generate the types.d.ts file disregarding the length and size of the file?

Notes.-

  • I ran my script in a MacOS (M2).
  • I ran the script against zsh and bash.
  • I used the following versions of NodeJS: 18.16.0 and 20.8.1.

TIA!

ArCiGo avatar Feb 26 '24 21:02 ArCiGo

maybe you report the wrong repo

brandonxiang avatar Mar 02 '24 12:03 brandonxiang

@ArCiGo did you install pbts for global? would you mind provide the test case as a repo?

brandonxiang avatar Jun 28 '24 01:06 brandonxiang