chartjs / chartjs-plugin-deferred

Chart.js plugin to defer initial chart updates
https://chartjs-plugin-deferred.netlify.app/
MIT License
108 stars 21 forks source link

$exports is not defined #33

Open handkerchief333 opened 1 year ago

handkerchief333 commented 1 year ago

I use "npm run build" to get the advantage of the bundle size. In my JS file I imported the ChartDeferred as follows:

import {
  Chart,
  Tooltip,
  Colors,
  BarController,
  CategoryScale,
  LinearScale,
  BarElement,
  Legend,
  BubbleController,
  PointElement,
} from 'chart.js';
import ChartDeferred from 'chartjs-plugin-deferred';

Chart.register(
    Tooltip,
    Colors,
    BarController,
    BarElement,
    CategoryScale,
    LinearScale,
    Legend,
    BubbleController,
    PointElement,
    ChartDeferred,
);

Without the ChartDeferred, the charts are working perfectly, but with ChartDeferred imported, this error appears and I can't get rid of this:

Uncaught ReferenceError: $50e8ddfc489f09fc$exports is not defined
    so chartjs-plugin-deferred.esm.js:83
    beforeInit chartjs-plugin-deferred.esm.js:98
    beforeInit chartjs-plugin-deferred.esm.js:144
    $ helpers.core.ts:109
    _notify core.plugins.js:60
    notify core.plugins.js:42
    notifyPlugins core.controller.js:1148
    _initialize core.controller.js:251
    on core.controller.js:204
    <anonymous> cc-chart.js:42

chart.js = 4.3.0 chartjs-plugin-deferred = 2.0.0

my package.json:

{
  "name": "example",
  "version": "1.0.0",
  "license": "MIT",
  "scripts": {
    "dev": "parcel src/index.html --no-content-hash",
    "build": "parcel build src/index.html --no-content-hash"
  },
  "devDependencies": {
    "parcel": "^2.6.2"
  },
  "dependencies": {
    "@cubejs-client/core": "^0.31.0",
    "chart.js": "^4.0.0",
    "chartjs-plugin-deferred": "^2.0.0"
  }
}
gregh3269 commented 1 year ago

For me using the umd version fixed the export issues.

handkerchief333 commented 1 year ago

For me using the umd version fixed the export issues.

@gregh3269 Thank you very much for your fast response. Maybe a stupid question, but can you describe to me exactly how to do this with my chosen integration?

gregh3269 commented 1 year ago

No sure it is related, its only a suggestion, for me it only seems works with http://cdn.jsdelivr.net/npm/chart.js@4.3.0/dist/chart.umd.js

maybe the "chart.js": "^4.0.0", defaults to the esm version?