diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 98% rename from .eslintrc.js rename to .eslintrc.cjs index 69d9d53d..934c8dad 100644 --- a/.eslintrc.js +++ b/.eslintrc.cjs @@ -31,5 +31,5 @@ module.exports = { } } ], - ignorePatterns: ['dist/**/*', 'node_modules/**/*', 'rollup.config.mjs'] + ignorePatterns: ['dist/**/*', 'node_modules/**/*', 'rollup.config.js'] } diff --git a/.size-limit.json b/.size-limit.json index dd0eb0b3..5261dc91 100644 --- a/.size-limit.json +++ b/.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", diff --git a/.storybook/manager.js b/.storybook/manager.js index da7d4c1a..7f903a97 100644 --- a/.storybook/manager.js +++ b/.storybook/manager.js @@ -1,6 +1,6 @@ import { addons } from '@storybook/addons' -import { theme } from './theme' +import { theme } from './theme.js' addons.setConfig({ theme, diff --git a/.storybook/package.json b/.storybook/package.json new file mode 100644 index 00000000..5bbefffb --- /dev/null +++ b/.storybook/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/package.json b/package.json index df8dd9d6..3347037e 100644 --- a/package.json +++ b/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 ", @@ -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": [ @@ -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": { diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 00000000..d2d47531 --- /dev/null +++ b/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 + } +} diff --git a/rollup.config.mjs b/rollup.config.mjs deleted file mode 100644 index 0b5b60ff..00000000 --- a/rollup.config.mjs +++ /dev/null @@ -1,45 +0,0 @@ -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.main, - plugins: plugins('defaults, not ie 11, not ie_mob 11'), - external, - output: { - format: 'cjs', - file: pkg.publishConfig.main, - exports: 'named', - sourcemap: true - } - }, - { - input: pkg.main, - plugins: plugins('defaults and supports es6-module'), - external, - output: { - format: 'es', - file: pkg.publishConfig.module, - sourcemap: true - } - } -] diff --git a/sandboxes/bar/package.json b/sandboxes/bar/package.json index 17f5a5dc..df369262 100644 --- a/sandboxes/bar/package.json +++ b/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", diff --git a/sandboxes/bar/src/App.vue b/sandboxes/bar/src/App.vue index 2cf53cdd..239a3ca0 100644 --- a/sandboxes/bar/src/App.vue +++ b/sandboxes/bar/src/App.vue @@ -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) diff --git a/sandboxes/bubble/package.json b/sandboxes/bubble/package.json index 17f5a5dc..df369262 100644 --- a/sandboxes/bubble/package.json +++ b/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", diff --git a/sandboxes/bubble/src/App.vue b/sandboxes/bubble/src/App.vue index 50693f1b..787e5d86 100644 --- a/sandboxes/bubble/src/App.vue +++ b/sandboxes/bubble/src/App.vue @@ -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) diff --git a/sandboxes/custom/package.json b/sandboxes/custom/package.json index 17f5a5dc..df369262 100644 --- a/sandboxes/custom/package.json +++ b/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", diff --git a/sandboxes/custom/src/App.vue b/sandboxes/custom/src/App.vue index a9007583..9ba2accc 100644 --- a/sandboxes/custom/src/App.vue +++ b/sandboxes/custom/src/App.vue @@ -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, diff --git a/sandboxes/doughnut/package.json b/sandboxes/doughnut/package.json index 17f5a5dc..df369262 100644 --- a/sandboxes/doughnut/package.json +++ b/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", diff --git a/sandboxes/doughnut/src/App.vue b/sandboxes/doughnut/src/App.vue index 085fb258..cfe2fca1 100644 --- a/sandboxes/doughnut/src/App.vue +++ b/sandboxes/doughnut/src/App.vue @@ -5,7 +5,7 @@