Skip to content

Commit 9043325

Browse files
authored
Provide auto-registering entry point (#8429)
1 parent c040b82 commit 9043325

File tree

6 files changed

+26
-0
lines changed

6 files changed

+26
-0
lines changed

auto/auto.esm.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { Chart } from '../dist/chart.esm';
2+
3+
export * from '../dist/chart.esm';
4+
export default Chart;

auto/auto.esm.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {Chart, registrables} from '../dist/chart.esm';
2+
3+
Chart.register(...registrables);
4+
5+
export default Chart;

auto/auto.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../dist/chart');

auto/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "chart.js-auto",
3+
"private": true,
4+
"description": "auto registering package",
5+
"main": "auto.js",
6+
"module": "auto.esm.js",
7+
"types": "auto.esm.d.ts"
8+
}

docs/docs/getting-started/integration.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ import { Chart, registerables } from 'chart.js';
9090
Chart.register(...registerables);
9191
```
9292

93+
And finally there is an separate path to do just the above for you, in one line:
94+
95+
```javascript
96+
import Chart from 'chart.js/auto';
97+
```
98+
9399
## Require JS
94100

95101
**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.).

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
"url": "https://github.com/chartjs/Chart.js/issues"
2626
},
2727
"files": [
28+
"auto/**/*.js",
29+
"auto/**/*.d.ts",
2830
"dist/*.js",
2931
"dist/*.d.ts",
3032
"dist/chunks/*.js",

0 commit comments

Comments
 (0)