Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ArCiGo opened this issue Feb 21, 2024 · 0 comments
Open

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

ArCiGo opened this issue Feb 21, 2024 · 0 comments

Comments

@ArCiGo
Copy link

ArCiGo commented Feb 21, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant