brandonxiang / protobuf-to-typescript

A converter from pb to typescript
https://pb.brandonxiang.top
MIT License
77 stars 15 forks source link

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

Open ArCiGo opened 8 months ago

ArCiGo commented 8 months ago

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.-

TIA!

brandonxiang commented 8 months ago

maybe you report the wrong repo

brandonxiang commented 4 months ago

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