Provide auto-registering entry point (#8429)

This commit is contained in:
Jukka Kurkela 2021-02-28 09:02:44 +02:00 committed by GitHub
parent c040b8255e
commit 9043325a6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 0 deletions

4
auto/auto.esm.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
import { Chart } from '../dist/chart.esm';
export * from '../dist/chart.esm';
export default Chart;

5
auto/auto.esm.js Normal file
View File

@ -0,0 +1,5 @@
import {Chart, registrables} from '../dist/chart.esm';
Chart.register(...registrables);
export default Chart;

1
auto/auto.js Normal file
View File

@ -0,0 +1 @@
module.exports = require('../dist/chart');

8
auto/package.json Normal file
View File

@ -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"
}

View File

@ -90,6 +90,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.).

View File

@ -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",