Skip to content

Vue3+Vite项目引入时报错 #7155

@aCoo4ie

Description

@aCoo4ie

根据官网的教程,通过 import G6 from @antv/g6 报错

Module '"/node_modules/@antv/g6/lib/index"' has no default export

版本号如下

npm list @antv/g6
frontend/
└── @antv/[email protected]

╰─❯ npm list vue
frontend/
├─┬ @vitejs/[email protected]
│ └── [email protected] deduped
├─┬ @vitejs/[email protected]
│ └── [email protected] deduped
├─┬ @vue/[email protected]
│ ├─┬ @vue/[email protected]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
├─┬ @vuelidate/[email protected]
│ ├─┬ [email protected]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
├─┬ @vuelidate/[email protected]
│ ├─┬ [email protected]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └─┬ @vuetify/[email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├── [email protected]
└─┬ [email protected]
└── [email protected] deduped

之后通过下面的issue暂时修复了。

Please update vite to latest version(2.8.x at present)

But it can't fix another issue, I also have the issue #3284 when I build my project by vite(rollup).

If anyone has the same problem, maybe would fix by setting config like this :


// vite.config.ts



{

  resolve: {

    alias: [

      {

          find: /^@antv\/g6/,

          replacement: path.resolve(

            __dirname,

            './node_modules/@antv/g6/dist/g6.min.js',

          ),

        },

    ]

  }

}

And this could help me solve my production build...

Originally posted by @luxferrew in #2961

想问下官方,使用Vue3+Vite,这个bug还没修复吗?

Metadata

Metadata

Assignees

No one assigned

    Labels

    waiting for maintainerTriage or intervention needed from a maintainer.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions