Skip to content

v3: consider changing export logic for esm modules #7371

@sgratzl

Description

@sgratzl

Feature Proposal

the in the v3 version the enhanced Chart module is exported as the solely (default) export from the library.

https://github.com/chartjs/Chart.js/blob/master/src/index.js

As an alternative one could have the following structure:

import ChartChart from './core/core.controller';
export { default as Chart } from './core/core.controller';
import DatasetController from './core/core.datasetController';
export { default as DatasetController }  from './core/core.datasetController';

class Chart extends ChartChart {
}
Chart.DatasetController = DatasetController;

export default Chart;

the purpose around the Chart class is that only the default export has all the dependencies but not the class itself.

Feature Use Case

I want to prepare for tree shaking and thus only import things that I really need. e.g.,

import {DatasetController} from 'chart.js';

class MyController extends DatasetController {
..}

note: while this works already with some synthetic imports (by rollup, ...) it is not standard conform.

Possible Implementation

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions