protobuf.js
protobuf.js copied to clipboard
sveltekit: TypeError: Cannot read properties of undefined (reading 'default')
trafficstars
protobuf.js version: 7.4.0
using svelte(kit)
pbjs -t static-module -w es6 -l -o ./src/lib/protos/index.js ./protos/*.proto && pbts -o ./src/lib/protos/index.d.ts ./src/lib/protos/index.js
import * as $protobuf from "protobufjs/minimal";
// Common aliases
const $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
// Exported root namespace
const $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
error:
[vite] Error when evaluating SSR module /src/lib/protos/index.js:
|- TypeError: Cannot read properties of undefined (reading 'default')
at ./src/lib/protos/index.js:7:30
at async instantiateModule (file://./node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:52972:5)
add: "protobufjs-cli": "^1.1.3"
test:
BAD:
import * as $protobuf from "protobufjs/minimal";
GOOD:
import $protobuf from "protobufjs/minimal";
@MineYuanlu did you find a workaround?
did you find a workaround?
@github-herve-bourzeix
I manually modified the code, and it works fine as long as it's changed like this:
import $protobuf from 'protobufjs/minimal';
Thanks, I could fix the issue using a sed script after compilation, any chance that we get it fixed on a new release?