fix: hotfix chart.js/auto for commonjs (#10992)

* fix: hotfix chart.js/auto for commonjs

* fix: add auto.cjs to side effects
This commit is contained in:
Dan Onoshko 2022-12-16 16:53:27 +04:00 committed by GitHub
parent 26f711df81
commit bc84a98ec6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 4 deletions

View 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);

View File

@ -7,6 +7,7 @@
"type": "module",
"sideEffects": [
"./auto/auto.js",
"./auto/auto.cjs",
"./dist/chart.umd.js"
],
"jsdelivr": "./dist/chart.umd.js",

View 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:*"

View File

@ -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)
});