Vite Migration: error does not provide an export

Viewed 5763

I'm trying to migrate from vue-cli to Vite using Vue 2.0.

I've some JavaScript-generated files for GRPC communication; alongside each file, there is a declarative file because I'm using Vue with TypeScript. When running Vite, I get this error:

Uncaught SyntaxError: The requested module '/src/proto/admin_config_grpc_web_pb.js' does not provide an export named 'AdminConfigurationServicePromiseClient'

However, I've a corresponding declaration file which contains this line:

export class AdminConfigurationServiceClient {

Anybody has encountered this issue and has a solution?

Thanks

2 Answers

This error is similar to the vite issue https://github.com/vitejs/vite/issues/2117.

Do not re-export typescript type or interface in vite. You can just export it in file A and import it in file B. Don't try to export it in file B again

BTW,

https://github.com/originjs/webpack-to-vite

This is a github project that I found when I searched for error messages when I was converting an old project. It lists some conversion items and error repair methods. It can even convert an old project to a vite project with one click. It’s great, I recommend it!

A workaround can be if you declare a new interface that inherits from the one that you want to re-export.

a.vue

export interface AItem extends ItemModel {}

b.vue

export interface A2Item extends ItemModel {}
Related