I am using Snowpack and trying to import Chart.js for Vue so I can display some data.
Getting this error:
Uncaught SyntaxError: The requested module '../_snowpack/pkg/chartjs.v3.2.0.js' does not provide an export named 'default'
package.json
"dependencies": {
"chart.js": "^3.2.0",
"vue": "^3.0.11",
"vue-chartjs": "^3.5.1"
},
"devDependencies": {
"@snowpack/plugin-dotenv": "^2.1.0",
"@snowpack/plugin-vue": "^2.4.0",
"snowpack": "^3.3.7"
}
I refered to Snowpack Common Errors but solutions they offer do not help in my case or I am doing something wrong.
snowpack.config
/** @type {import("snowpack").SnowpackUserConfig } */
module.exports = {
mount: {
public: { url: '/', static: true },
src: { url: '/dist' },
},
plugins: ['@snowpack/plugin-vue', '@snowpack/plugin-dotenv'],
routes: [
/* Enable an SPA Fallback in development: */
// {"match": "routes", "src": ".*", "dest": "/index.html"},
],
optimize: {
/* Example: Bundle your final build: */
// "bundle": true,
},
packageOptions: {
namedExports: ['vue-chartjs', 'chart.js'],
},
devOptions: {
/* ... */
},
buildOptions: {
/* ... */
},
};
Chart.js
import { Bar } from 'vue-chartjs'
export default {
extends: Bar,
mounted () {
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [
{
label: 'GitHub Commits',
backgroundColor: '#f87979',
data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
}
]
})
}
}
Can anyone has any idea for a workaround?