Publishing an extension

If you are planning on publishing an extension for Chart.js, here are some pointers.

Awesome

You’d probably want your extension to be listed in the awesomePublishing an extension - 图1 (opens new window).

Note the minimum extension age requirement of 30 days.

ESM

If you are utilizing ESM, you probably still want to publish a UMD bundle of your extension. Because Chart.js v3 is tree shakeable, the interface is a bit different. UMD package’s global Chart includes everything, while ESM package exports all the things separately. Fortunately, most of the exports can be mapped automatically by the bundlers.

But not the helpers.

In UMD, helpers are available through Chart.helpers. In ESM, they are imported from chart.js/helpers.

For example import {isNullOrUndef} from 'chart.js/helpers' is available at Chart.helpers.isNullOrUndef for UMD.

Rollup

output.globals can be used to convert the helpers.

  1. module.exports = {
  2. // ...
  3. output: {
  4. globals: {
  5. 'chart.js': 'Chart',
  6. 'chart.js/helpers': 'Chart.helpers'
  7. }
  8. }
  9. };