question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v3: consider changing export logic for esm modules

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:29 (28 by maintainers)

github_iconTop GitHub Comments

2reactions
benmccanncommented, Jul 20, 2020

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 the parse method in the date adapters is not called

2reactions
benmccanncommented, Jul 17, 2020

any day now

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found