Cannot import a class from a WebPacked javascript file

15 views Asked by At

I have a very simple client.js file importing the generated grpc stubs (from the simplest grpc Hello World example):

const { HelloRequest, HelloReply } = require('./greet_pb.js');
const { GreeterClient } = require('./greet_grpc_web_pb.js');

export default class Greeter {
    HelloRequest = HelloRequest;
    HelloReply = HelloReply;
    GreeterClient = GreeterClient;
}

I bundle it (together with its dependencies) into the dist/main.js file using webpack.

Then I am trying to import it into my Index.html, I tried placing

import Greeter from './dist/main.js'

or

import Greeter from './client.js'

within <script type='module'></script>

and nothing works.

Please, help!

0

There are 0 answers