From: Jukka Kurkela Date: Sun, 28 Feb 2021 07:02:44 +0000 (+0200) Subject: Provide auto-registering entry point (#8429) X-Git-Tag: v3.0.0-beta.13~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9043325a6e9cdec340a5d3b48f8e54095e6814f9;p=thirdparty%2FChart.js.git Provide auto-registering entry point (#8429) --- diff --git a/auto/auto.esm.d.ts b/auto/auto.esm.d.ts new file mode 100644 index 000000000..d83b83515 --- /dev/null +++ b/auto/auto.esm.d.ts @@ -0,0 +1,4 @@ +import { Chart } from '../dist/chart.esm'; + +export * from '../dist/chart.esm'; +export default Chart; diff --git a/auto/auto.esm.js b/auto/auto.esm.js new file mode 100644 index 000000000..f4b5711ec --- /dev/null +++ b/auto/auto.esm.js @@ -0,0 +1,5 @@ +import {Chart, registrables} from '../dist/chart.esm'; + +Chart.register(...registrables); + +export default Chart; diff --git a/auto/auto.js b/auto/auto.js new file mode 100644 index 000000000..235580fef --- /dev/null +++ b/auto/auto.js @@ -0,0 +1 @@ +module.exports = require('../dist/chart'); diff --git a/auto/package.json b/auto/package.json new file mode 100644 index 000000000..c2ad5b2ca --- /dev/null +++ b/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" +} diff --git a/docs/docs/getting-started/integration.md b/docs/docs/getting-started/integration.md index 690ec2316..d701d9d3a 100644 --- a/docs/docs/getting-started/integration.md +++ b/docs/docs/getting-started/integration.md @@ -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.). diff --git a/package.json b/package.json index cf10f934b..6e0c84cad 100644 --- a/package.json +++ b/package.json @@ -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",