Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide auto-registering entry point #8429

Merged
merged 1 commit into from Feb 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions auto/auto.esm.d.ts
@@ -0,0 +1,4 @@
import { Chart } from '../dist/chart.esm';

export * from '../dist/chart.esm';
export default Chart;
5 changes: 5 additions & 0 deletions auto/auto.esm.js
@@ -0,0 +1,5 @@
import {Chart, registrables} from '../dist/chart.esm';

Chart.register(...registrables);

export default Chart;
1 change: 1 addition & 0 deletions auto/auto.js
@@ -0,0 +1 @@
module.exports = require('../dist/chart');
8 changes: 8 additions & 0 deletions auto/package.json
@@ -0,0 +1,8 @@
{
"name": "chart.js-auto",
"private": true,
"description": "auto registering package",
"main": "auto.js",
"module": "auto.esm.js",
"types": "auto.esm.d.ts"
}
7 changes: 7 additions & 0 deletions docs/docs/getting-started/integration.md
Expand Up @@ -25,6 +25,7 @@ var myChart = new Chart(ctx, {...});
Chart.js 3 is tree-shakeable, so it is necessary to import and register the controllers, elements, scales and plugins you are going to use.

For all available imports see the example below.

```javascript
import {
Chart,
Expand Down Expand Up @@ -87,6 +88,12 @@ import { Chart, registerables } from 'chart.js';
Chart.register(...registerables);
```

And finally there is an separate path to do just the above for you, in one line:

```javascript
import Chart from 'chart.js/auto';
```

## Require JS

**Important:** RequireJS [can **not** load CommonJS module as is](https://requirejs.org/docs/commonjs.html#intro), so be sure to require one of the UMD builds instead (i.e. `dist/chart.js`, `dist/chart.min.js`, etc.).
Expand Down
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -25,6 +25,8 @@
"url": "https://github.com/chartjs/Chart.js/issues"
},
"files": [
"auto/**/*.js",
"auto/**/*.d.ts",
"dist/*.js",
"dist/*.d.ts",
"dist/chunks/*.js",
Expand Down