Skip to content

Commit

Permalink
fix: hotfix chart.js/auto for commonjs (#10992)
Browse files Browse the repository at this point in the history
* fix: hotfix chart.js/auto for commonjs

* fix: add auto.cjs to side effects
  • Loading branch information
dangreen committed Dec 16, 2022
1 parent 26f711d commit bc84a98
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
6 changes: 3 additions & 3 deletions 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);
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -7,6 +7,7 @@
"type": "module",
"sideEffects": [
"./auto/auto.js",
"./auto/auto.cjs",
"./dist/chart.umd.js"
],
"jsdelivr": "./dist/chart.umd.js",
Expand Down
4 changes: 3 additions & 1 deletion test/integration/node-commonjs/package.json
Expand Up @@ -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:*"
Expand Down
7 changes: 7 additions & 0 deletions 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)
});

0 comments on commit bc84a98

Please sign in to comment.