kouts / vue-dataset

A set of Vue.js components to display datasets (lists) with filtering, paging, and sorting capabilities!
https://next--vue-dataset-demo.netlify.app/
MIT License
220 stars 25 forks source link

Vite import problem and workaround #118

Open brianmercer opened 1 year ago

brianmercer commented 1 year ago

Using Vitepress and Vite with SSR, I used this import:

  import { 
    Dataset,
    DatasetItem,
    DatasetInfo,
    DatasetPager,
    DatasetSearch,
    DatasetShow
  } from 'vue-dataset'

and received this error:

SyntaxError: Named export 'Dataset' not found. The requested module 'vue-dataset' is a CommonJS module, which may not support all module.exports as named exports.

I don't know exactly what Vite doesn't like about the package but I found a workaround using:

// vite.config.js

export default {
  ssr: {
    // Add npm packages containing invalid code here
    noExternal: ['vue-dataset']
  }
}

from this page: https://vite-plugin-ssr.com/broken-npm-package#solution