]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
fix: hotfix chart.js/auto for commonjs (#10992)
authorDan Onoshko <danon0404@gmail.com>
Fri, 16 Dec 2022 12:53:27 +0000 (16:53 +0400)
committerGitHub <noreply@github.com>
Fri, 16 Dec 2022 12:53:27 +0000 (07:53 -0500)
* fix: hotfix chart.js/auto for commonjs

* fix: add auto.cjs to side effects

auto/auto.cjs
package.json
test/integration/node-commonjs/package.json
test/integration/node-commonjs/test-auto.js [new file with mode: 0644]

index 4a4590a4b0fda8c0ce2f2ec080f8d72176b50455..62e08b16dfc2f6e83a9673fe018a8dce5c6d18ae 100644 (file)
@@ -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);
index cac1fb077aa7ca37197851ddc8a1f8b8df33a12e..3b990e8f8083020bcfadd8cdf63d491054028f8f 100644 (file)
@@ -7,6 +7,7 @@
     "type": "module",
     "sideEffects": [
         "./auto/auto.js",
+        "./auto/auto.cjs",
         "./dist/chart.umd.js"
     ],
     "jsdelivr": "./dist/chart.umd.js",
index 19c9b2c0ccc66f0084c398c6cf124c0498240300..b2a0e280434e686c687209112f20930cb391ea3f 100644 (file)
@@ -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 (file)
index 0000000..a0a58ff
--- /dev/null
@@ -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)
+});