# 发布扩展
¥Publishing an extension
如果你计划发布 Chart.js 的扩展,这里有一些建议。
¥If you are planning on publishing an extension for Chart.js, here are some pointers.
# Awesome
你可能希望你的扩展名列在 awesome (opens new window)。
¥You'd probably want your extension to be listed in the awesome (opens new window).
请注意 30 天的最低延期年龄要求。
¥Note the minimum extension age requirement of 30 days.
# ESM
如果你正在使用 ESM,你可能仍想发布扩展的 UMD 包。因为 Chart.js v3 是 tree shakeable,界面有点不同。UMD 包的全局 Chart
包含所有内容,而 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.
在 UMD 中,可以通过 Chart.helpers
获得助手。在 ESM 中,它们是从 chart.js/helpers
导入的。
¥In UMD, helpers are available through Chart.helpers
. In ESM, they are imported from chart.js/helpers
.
例如,对于 UMD,import {isNullOrUndef} from 'chart.js/helpers'
在 Chart.helpers.isNullOrUndef
可用。
¥For example import {isNullOrUndef} from 'chart.js/helpers'
is available at Chart.helpers.isNullOrUndef
for UMD.
# Rollup
output.globals
可用于转换助手。
¥output.globals
can be used to convert the helpers.
module.exports = {
// ...
output: {
globals: {
'chart.js': 'Chart',
'chart.js/helpers': 'Chart.helpers'
}
}
};