-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recompile tx-signer.proto with the option
importSuffix=.js
Importing `pocketjs-transaction-builder` as an ES module caused ERR_MODULE_NOT_FOUND because index.js imported protobufjs without extension like `import r from"protobufjs/minimal"`. This patch updates the script to compile .proto with the new option `importSuffix`, which was introduced in ts-proto v1.117.0, to add ".js" extension in importing statements.
- Loading branch information
Showing
10 changed files
with
1,161 additions
and
1,116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,7 @@ | |
export default { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
moduleNameMapper: { | ||
"^(\\.\\/.+)\\.js$": "$1", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
protoc --plugin=../../../node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=generated ./tx-signer.proto --ts_proto_opt=esModuleInterop=true | ||
#!/bin/sh | ||
|
||
# when running this gen file import * as _m0 from "protobufjs/minimal" causes import bugs and does not result in same import pattern as previous releases. | ||
# This commit here shows that potentially it was manually added (https://github.com/pokt-foundation/pocket-js/commit/00e85a5c0b6a20ced85a3df7a12bb25004d691a9#diff-ecd6dda6a974a6196f2d4d4681856ae6668c31a4f0a45a0d06b8cb2c74739273R8) | ||
# Not sure how modify gen script to result in same import, so the below statements will replace import * as _m0 from "protobufjs/minimal" to import _m0 from "protobufjs/minimal" | ||
file_paths=( | ||
"generated/tx-signer.ts" | ||
"generated/google/protobuf/any.ts" | ||
) | ||
[ -d generated ] && rm -rf generated | ||
mkdir generated | ||
|
||
# Perform the import replacement for each file path using a for loop | ||
for file_path in "${file_paths[@]}"; do | ||
sed -i 's/import \* as _m0 from '\''protobufjs\/minimal'\''/import _m0 from '\''protobufjs\/minimal'\''/' "$file_path" | ||
done | ||
protoc --plugin=../../../node_modules/.bin/protoc-gen-ts_proto \ | ||
--ts_proto_out=generated \ | ||
--ts_proto_opt=esModuleInterop=true \ | ||
--ts_proto_opt=importSuffix=.js \ | ||
./tx-signer.proto |
1 change: 0 additions & 1 deletion
1
packages/transaction-builder/src/models/proto/generated/google/index.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
packages/transaction-builder/src/models/proto/generated/google/protobuf/index.ts
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
packages/transaction-builder/src/models/proto/generated/index.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.