Skip to content

Commit

Permalink
feat: upgrade Chart.js to v4 (#960)
Browse files Browse the repository at this point in the history
Chart.js v4 support

BREAKING CHANGE: package now is ESM-only, no CommonJS support
  • Loading branch information
dangreen committed Dec 5, 2022
1 parent 5ab27bc commit 7fd4ae4
Show file tree
Hide file tree
Showing 51 changed files with 139 additions and 144 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js → .eslintrc.cjs
Expand Up @@ -31,5 +31,5 @@ module.exports = {
}
}
],
ignorePatterns: ['dist/**/*', 'node_modules/**/*', 'rollup.config.mjs']
ignorePatterns: ['dist/**/*', 'node_modules/**/*', 'rollup.config.js']
}
11 changes: 0 additions & 11 deletions .size-limit.json
@@ -1,15 +1,4 @@
[
{
"path": "dist/index.cjs",
"limit": "1.75 KB",
"webpack": false,
"running": false
},
{
"path": "dist/index.cjs",
"limit": "1 KB",
"import": "{ Bar }"
},
{
"path": "dist/index.js",
"limit": "1.7 KB",
Expand Down
2 changes: 1 addition & 1 deletion .storybook/manager.js
@@ -1,6 +1,6 @@
import { addons } from '@storybook/addons'

import { theme } from './theme'
import { theme } from './theme.js'

addons.setConfig({
theme,
Expand Down
3 changes: 3 additions & 0 deletions .storybook/package.json
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
11 changes: 7 additions & 4 deletions package.json
@@ -1,5 +1,6 @@
{
"name": "vue-chartjs",
"type": "module",
"version": "4.1.2",
"description": "Vue.js wrapper for chart.js for creating beautiful charts.",
"author": "Jakub Juszczak <jakub@posteo.de>",
Expand Down Expand Up @@ -37,11 +38,13 @@
"Charts"
],
"sideEffects": false,
"main": "./src/index.ts",
"types": "./dist/index.d.ts",
"exports": "./src/index.ts",
"publishConfig": {
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"exports": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"directory": "package"
},
"files": [
Expand All @@ -68,7 +71,7 @@
"updateGitHooks": "simple-git-hooks"
},
"peerDependencies": {
"chart.js": "^3.7.0",
"chart.js": "^4.0.0",
"vue": "^3.0.0-0 || ^2.6.0"
},
"devDependencies": {
Expand Down
32 changes: 32 additions & 0 deletions rollup.config.js
@@ -0,0 +1,32 @@
import { swc } from 'rollup-plugin-swc3'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import pkg from './package.json' assert { type: 'json' }

const extensions = ['.js', '.ts']
const external = _ => /node_modules/.test(_) && !/@swc\/helpers/.test(_)
const plugins = targets => [
nodeResolve({
extensions
}),
swc({
tsconfig: false,
env: {
targets
},
module: {
type: 'es6'
},
sourceMaps: true
})
]

export default {
input: pkg.exports,
plugins: plugins('defaults and supports es6-module'),
external,
output: {
format: 'es',
file: pkg.publishConfig.exports.import,
sourcemap: true
}
}
45 changes: 0 additions & 45 deletions rollup.config.mjs

This file was deleted.

5 changes: 3 additions & 2 deletions sandboxes/bar/package.json
@@ -1,11 +1,12 @@
{
"type": "module",
"scripts": {
"start": "vite"
},
"dependencies": {
"chart.js": "^3.8.0",
"chart.js": "^4.0.0",
"vue": "^3.2.31",
"vue-chartjs": "^4.0.0"
"vue-chartjs": "^5.0.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion sandboxes/bar/src/App.vue
Expand Up @@ -13,7 +13,7 @@ import {
LinearScale
} from 'chart.js'
import { Bar } from 'vue-chartjs'
import * as chartConfig from './chartConfig'
import * as chartConfig from './chartConfig.js'
ChartJS.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend)
Expand Down
5 changes: 3 additions & 2 deletions sandboxes/bubble/package.json
@@ -1,11 +1,12 @@
{
"type": "module",
"scripts": {
"start": "vite"
},
"dependencies": {
"chart.js": "^3.8.0",
"chart.js": "^4.0.0",
"vue": "^3.2.31",
"vue-chartjs": "^4.0.0"
"vue-chartjs": "^5.0.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion sandboxes/bubble/src/App.vue
Expand Up @@ -11,7 +11,7 @@ import {
LinearScale
} from 'chart.js'
import { Bubble } from 'vue-chartjs'
import * as chartConfig from './chartConfig'
import * as chartConfig from './chartConfig.js'
ChartJS.register(LinearScale, PointElement, Tooltip, Legend)
Expand Down
5 changes: 3 additions & 2 deletions sandboxes/custom/package.json
@@ -1,11 +1,12 @@
{
"type": "module",
"scripts": {
"start": "vite"
},
"dependencies": {
"chart.js": "^3.8.0",
"chart.js": "^4.0.0",
"vue": "^3.2.31",
"vue-chartjs": "^4.0.0"
"vue-chartjs": "^5.0.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.0.1",
Expand Down
4 changes: 2 additions & 2 deletions sandboxes/custom/src/App.vue
Expand Up @@ -13,8 +13,8 @@ import {
Tooltip,
Legend
} from 'chart.js'
import LineWithLineChart from './components/LineWithLineChart'
import * as chartConfig from './chartConfig'
import LineWithLineChart from './components/LineWithLineChart.js'
import * as chartConfig from './chartConfig.js'
ChartJS.register(
CategoryScale,
Expand Down
5 changes: 3 additions & 2 deletions sandboxes/doughnut/package.json
@@ -1,11 +1,12 @@
{
"type": "module",
"scripts": {
"start": "vite"
},
"dependencies": {
"chart.js": "^3.8.0",
"chart.js": "^4.0.0",
"vue": "^3.2.31",
"vue-chartjs": "^4.0.0"
"vue-chartjs": "^5.0.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion sandboxes/doughnut/src/App.vue
Expand Up @@ -5,7 +5,7 @@
<script lang="ts">
import { Chart as ChartJS, ArcElement, Tooltip, Legend } from 'chart.js'
import { Doughnut } from 'vue-chartjs'
import * as chartConfig from './chartConfig'
import * as chartConfig from './chartConfig.js'
ChartJS.register(ArcElement, Tooltip, Legend)
Expand Down
5 changes: 3 additions & 2 deletions sandboxes/line/package.json
@@ -1,11 +1,12 @@
{
"type": "module",
"scripts": {
"start": "vite"
},
"dependencies": {
"chart.js": "^3.8.0",
"chart.js": "^4.0.0",
"vue": "^3.2.31",
"vue-chartjs": "^4.0.0"
"vue-chartjs": "^5.0.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion sandboxes/line/src/App.vue
Expand Up @@ -14,7 +14,7 @@ import {
Legend
} from 'chart.js'
import { Line } from 'vue-chartjs'
import * as chartConfig from './chartConfig'
import * as chartConfig from './chartConfig.js'
ChartJS.register(
CategoryScale,
Expand Down
5 changes: 3 additions & 2 deletions sandboxes/pie/package.json
@@ -1,11 +1,12 @@
{
"type": "module",
"scripts": {
"start": "vite"
},
"dependencies": {
"chart.js": "^3.8.0",
"chart.js": "^4.0.0",
"vue": "^3.2.31",
"vue-chartjs": "^4.0.0"
"vue-chartjs": "^5.0.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion sandboxes/pie/src/App.vue
Expand Up @@ -5,7 +5,7 @@
<script lang="ts">
import { Chart as ChartJS, ArcElement, Tooltip, Legend } from 'chart.js'
import { Pie } from 'vue-chartjs'
import * as chartConfig from './chartConfig'
import * as chartConfig from './chartConfig.js'
ChartJS.register(ArcElement, Tooltip, Legend)
Expand Down
2 changes: 1 addition & 1 deletion sandboxes/polar-area/src/App.vue
Expand Up @@ -11,7 +11,7 @@ import {
Legend
} from 'chart.js'
import { PolarArea } from 'vue-chartjs'
import * as chartConfig from './chartConfig'
import * as chartConfig from './chartConfig.js'
ChartJS.register(RadialLinearScale, ArcElement, Tooltip, Legend)
Expand Down
5 changes: 3 additions & 2 deletions sandboxes/radar/package.json
@@ -1,11 +1,12 @@
{
"type": "module",
"scripts": {
"start": "vite"
},
"dependencies": {
"chart.js": "^3.8.0",
"chart.js": "^4.0.0",
"vue": "^3.2.31",
"vue-chartjs": "^4.0.0"
"vue-chartjs": "^5.0.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion sandboxes/radar/src/App.vue
Expand Up @@ -13,7 +13,7 @@ import {
Legend
} from 'chart.js'
import { Radar } from 'vue-chartjs'
import * as chartConfig from './chartConfig'
import * as chartConfig from './chartConfig.js'
ChartJS.register(
RadialLinearScale,
Expand Down
5 changes: 3 additions & 2 deletions sandboxes/reactive/package.json
@@ -1,11 +1,12 @@
{
"type": "module",
"scripts": {
"start": "vite"
},
"dependencies": {
"chart.js": "^3.8.0",
"chart.js": "^4.0.0",
"vue": "^3.2.31",
"vue-chartjs": "^4.0.0"
"vue-chartjs": "^5.0.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion sandboxes/reactive/src/App.vue
Expand Up @@ -15,7 +15,7 @@ import {
ChartData
} from 'chart.js'
import { Bar } from 'vue-chartjs'
import * as chartConfig from './chartConfig'
import * as chartConfig from './chartConfig.js'
ChartJS.register(Title, Tooltip, Legend, BarElement, CategoryScale, LinearScale)
Expand Down
5 changes: 3 additions & 2 deletions sandboxes/scatter/package.json
@@ -1,11 +1,12 @@
{
"type": "module",
"scripts": {
"start": "vite"
},
"dependencies": {
"chart.js": "^3.8.0",
"chart.js": "^4.0.0",
"vue": "^3.2.31",
"vue-chartjs": "^4.0.0"
"vue-chartjs": "^5.0.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion sandboxes/scatter/src/App.vue
Expand Up @@ -12,7 +12,7 @@ import {
Legend
} from 'chart.js'
import { Scatter } from 'vue-chartjs'
import * as chartConfig from './chartConfig'
import * as chartConfig from './chartConfig.js'
ChartJS.register(LinearScale, PointElement, LineElement, Tooltip, Legend)
Expand Down
7 changes: 4 additions & 3 deletions src/chart.ts
Expand Up @@ -9,15 +9,16 @@ import {
toRaw
} from 'vue'
import { Chart as ChartJS } from 'chart.js'
import { Props } from './props'
import type { ChartComponent } from './types.js'
import { Props } from './props.js'
import {
cloneData,
setLabels,
setDatasets,
setOptions,
toRawIfProxy,
cloneProxy
} from './utils'
} from './utils.js'

export const Chart = defineComponent({
props: Props,
Expand Down Expand Up @@ -113,4 +114,4 @@ export const Chart = defineComponent({
})
}
}
})
}) as ChartComponent

0 comments on commit 7fd4ae4

Please sign in to comment.