Skip to content

Probably invalid $protobuf import statement in static module #1657

@charlie-wasp

Description

@charlie-wasp

protobuf.js version: 6.9.0

Hi! I want to use CLI to generate static code from my .proto file. I used the next command:

$ yarn pbjs -t static-module -w es6 -o packages/protobuf-encoder/generated/message_pb.js message.proto

But it seems that generated file contains invalid import statement on top:

// message_pb.js file
import * as $protobuf from "protobufjs/minimal";

...

If we look at minimal.js file, we'll find there CommonJS-style export module.exports = require("./src/index-minimal");. AFAIK in ES6 we can import such modules, using only default export. So the valid import should be import $protobuf from "protobufjs/minimal". I edited the generated file manually and it works now.

Am I missing something here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions