vueuse / vue-chemistry

Reactified JavaScript functions for Vue
MIT License
392 stars 9 forks source link

Importing "vue-chemistry" and "vue-chemistry/math" occurs error with vite #4

Closed sapphi-red closed 3 years ago

sapphi-red commented 3 years ago
import { reactify, set } from 'vue-chemistry'
import { sum } from 'vue-chemistry/math'

This occues the error below with vite@2.0.0-beta.31.

[plugin:vite:import-analysis] Deep import "vue-chemistry/math" should be avoided
because dependency "vue-chemistry" has been pre-optimized.
Prefer importing directly from the module entry:

import { ... } from "vue-chemistry"

If the used import is not exported from the package's main entry and can only be attained via deep import,
you can explicitly add the deep import path to "optimizeDeps.include" in vite.config.js.

By excluding this package from optimizeDeps fixes this, but maybe renaming vue-chemistry/all to vue-chemistry and vue-chemistry to vue-chemistry/core would be better?

  optimizeDeps: {
    exclude: ['vue-chemistry']
  }
antfu commented 3 years ago

renaming vue-chemistry/all to vue-chemistry and vue-chemistry to vue-chemistry/core would be better?

Sounds reasonable, wanna draft a PR for it? Thanks.

sapphi-red commented 3 years ago

Sure, Ill do it 👍