From 6cbcd55205bf8afe5f9b630680cd767150799e0a Mon Sep 17 00:00:00 2001 From: dangreen Date: Fri, 16 Dec 2022 13:10:24 +0400 Subject: [PATCH] fix: hotfix chart.js/auto for commonjs --- auto/auto.cjs | 6 +++--- test/integration/node-commonjs/package.json | 4 +++- test/integration/node-commonjs/test-auto.js | 7 +++++++ 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 test/integration/node-commonjs/test-auto.js diff --git a/auto/auto.cjs b/auto/auto.cjs index 4a4590a4b0f..62e08b16dfc 100644 --- a/auto/auto.cjs +++ b/auto/auto.cjs @@ -1,6 +1,6 @@ -const exports = require('../dist/chart.cjs'); -const {Chart, registerables} = exports; +const chartjs = require('../dist/chart.cjs'); +const {Chart, registerables} = chartjs; Chart.register(...registerables); -module.exports = Object.assign(Chart, exports); +module.exports = Object.assign(Chart, chartjs); diff --git a/test/integration/node-commonjs/package.json b/test/integration/node-commonjs/package.json index 19c9b2c0ccc..b2a0e280434 100644 --- a/test/integration/node-commonjs/package.json +++ b/test/integration/node-commonjs/package.json @@ -2,7 +2,9 @@ "private": true, "description": "chart.js should work in Node", "scripts": { - "test": "node test.js" + "test": "npm run test-index && npm run test-auto", + "test-index": "node test.js", + "test-auto": "node test-auto.js" }, "dependencies": { "chart.js": "workspace:*" diff --git a/test/integration/node-commonjs/test-auto.js b/test/integration/node-commonjs/test-auto.js new file mode 100644 index 00000000000..a0a58ff619e --- /dev/null +++ b/test/integration/node-commonjs/test-auto.js @@ -0,0 +1,7 @@ +const Chart = require('chart.js/auto'); +const {valueOrDefault} = require('chart.js/helpers'); + +Chart.register({ + id: 'TEST_PLUGIN', + dummyValue: valueOrDefault(0, 1) +});