v3: consider changing export logic for esm modules
See original GitHub issueFeature 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
Issue Analytics
- State:
- Created 3 years ago
- Comments:29 (28 by maintainers)
Top Results From Across the Web
ECMAScript modules | Node.js v19.3.0 Documentation
Like in CommonJS, module files within packages can be accessed by appending a path to the package name unless the package's package. json...
Read more >Using ES modules in Node.js
Another way is if the package's package. json contains an exports field where the files within packages can only be accessed via the...
Read more >What does it take to support Node.js ESM?
exports is available, and since support for Node.js v10.x is dropped, everything should be fine and supporting ESM shouldn't be that hard. After ......
Read more >The Complete Guide to Modules in Browsers and Node.
Everything inside an ES2015 module is private by default. The export statement exposes public properties, functions, and classes; the import ...
Read more >ECMAScript Modules
The export keyword allows to expose things from an ESM to other modules: ... is exposed // it's not possible to modify the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve sent fixes for the date adapters: https://github.com/chartjs/chartjs-adapter-luxon/pull/20 https://github.com/chartjs/chartjs-adapter-date-fns/pull/16
In the meantime, you can avoid any issues by supplying timestamps and setting
parsing: false
so that theparse
method in the date adapters is not calledany day now