Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions docs/.vuepress/config.js → docs/.vuepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const path = require('path');
import * as path from 'path';
import markdownItInclude from 'markdown-it-include';
import { DefaultThemeConfig, defineConfig, PluginTuple } from 'vuepress/config';

const docsVersion = "VERSION";
const base = process.env.NODE_ENV === "development" ? '/chartjs-plugin-annotation/master/' : `/chartjs-plugin-annotation/${docsVersion}/`;

module.exports = {
export default defineConfig({
dest: 'dist/docs',
title: 'chartjs-plugin-annotation',
description: 'Annotations for Chart.js',
Expand Down Expand Up @@ -72,7 +75,7 @@ module.exports = {
]
},
}],
],
] as PluginTuple[],
chainWebpack(config) {
config.module
.rule('chart.js')
Expand All @@ -86,7 +89,7 @@ module.exports = {
},
markdown: {
extendMarkdown: md => {
md.use(require('markdown-it-include'), path.resolve(__dirname, '../'));
md.use(markdownItInclude, path.resolve(__dirname, '../'));
}
},
themeConfig: {
Expand Down Expand Up @@ -220,5 +223,5 @@ module.exports = {
'utils',
]
}
}
};
} as DefaultThemeConfig
});
9 changes: 5 additions & 4 deletions karma.conf.js → karma.conf.cjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const jasmineSeedReporter = require('./test/seed-reporter');
const istanbul = require('rollup-plugin-istanbul');
const json = require('@rollup/plugin-json');
const resolve = require('@rollup/plugin-node-resolve').default;
const builds = require('./rollup.config');
const yargs = require('yargs');
const env = process.env.NODE_ENV;

module.exports = function(karma) {
module.exports = async function(karma) {
const builds = (await import('./rollup.config.js')).default;
const jasmineSeedReporter = (await import('./test/seed-reporter.js')).default;

const args = yargs
.option('verbose', {default: false})
.argv;
Expand All @@ -15,7 +16,7 @@ module.exports = function(karma) {
// we will prefer the unminified build which is easier to browse and works
// better with source mapping. In other cases, pick the minified build to
// make sure that the minification process (terser) doesn't break anything.
const regex = karma.autoWatch ? /chartjs-plugin-annotation\.js$/ : /chartjs-plugin-annotation\.min\.js$/;
const regex = karma.autoWatch ? /chartjs-plugin-annotation\.cjs$/ : /chartjs-plugin-annotation\.min\.js$/;
const build = builds.filter(v => v.output.file && v.output.file.match(regex))[0];

if (env === 'test') {
Expand Down
70 changes: 33 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 22 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@
"version": "2.1.0",
"author": "Evert Timberg <evert.timberg@gmail.com>",
"license": "MIT",
"main": "dist/chartjs-plugin-annotation.js",
"type": "module",
"main": "dist/chartjs-plugin-annotation.cjs",
"module": "dist/chartjs-plugin-annotation.esm.js",
"types": "types/index.d.ts",

"jsdelivr": "dist/chartjs-plugin-annotation.min.js",
"unpkg": "dist/chartjs-plugin-annotation.min.js",
"exports": {
"types": "./types/index.d.ts",
"import": "./dist/chartjs-plugin-annotation.esm.js",
"require": "./dist/chartjs-plugin-annotation.cjs",
"script": "./dist/chartjs-plugin-annotation.min.js"
},
"sideEffects": false,
"repository": {
"type": "git",
"url": "https://github.com/chartjs/chartjs-plugin-annotation.git"
Expand All @@ -18,30 +29,27 @@
],
"scripts": {
"build": "rollup -c",
"dev": "karma start --auto-watch --no-single-run --browsers chrome",
"dev:ff": "karma start --auto-watch --no-single-run --browsers firefox",
"dev": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers chrome",
"dev:ff": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers firefox",
"docs": "npm run build && vuepress build docs --no-cache",
"docs:dev": "npm run build && vuepress dev docs --no-cache",
"lint": "concurrently --group \"npm:lint-*\"",
"lint-js": "eslint \"test/**/*.js\" \"src/**/*.js\"",
"lint-md": "eslint \"**/*.md\"",
"lint-types": "eslint \"types/**/*.ts\" && tsc -p types/tests/",
"test": "cross-env NODE_ENV=test concurrently --group \"npm:test-*\"",
"test-karma": "karma start --auto-watch --single-run",
"test-karma": "karma start ./karma.conf.cjs --auto-watch --single-run",
"test-lint": "npm run lint",
"test-types": "tsc -p types/tests/",
"test-types-integration": "mocha --full-trace test/integration/*-test.js"
},
"devDependencies": {
"@babel/core": "^7.20.2",
"@babel/preset-env": "^7.20.2",
"@rollup/plugin-json": "^5.0.1",
"@rollup/plugin-json": "^5.0.2",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.1.0",
"@simonbrunel/vuepress-plugin-versions": "^0.2.0",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"babel-loader": "^8.3.0",
"chart.js": "^4.0.1",
"chartjs-plugin-autocolors": "^0.0.5",
"chartjs-test-utils": "^0.5.0",
Expand All @@ -53,17 +61,17 @@
"eslint-plugin-html": "^6.1.2",
"eslint-plugin-markdown": "^2.0.1",
"fs-extra": "^10.0.0",
"karma": "^6.3.2",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "^2.0.3",
"karma-firefox-launcher": "^2.1.0",
"karma": "^6.4.1",
"karma-chrome-launcher": "^3.1.1",
"karma-coverage": "^2.2.0",
"karma-firefox-launcher": "^2.1.2",
"karma-jasmine": "^5.1.0",
"karma-jasmine-html-reporter": "^2.0.0",
"karma-rollup-preprocessor": "^7.0.7",
"markdown-it-include": "^2.0.0",
"mocha": "^9.1.3",
"pixelmatch": "^5.2.1",
"rollup": "^3.3.0",
"rollup": "^3.7.0",
"rollup-plugin-istanbul": "^4.0.0",
"typedoc": "^0.23.8",
"typedoc-plugin-markdown": "^3.13.3",
Expand All @@ -72,8 +80,7 @@
"vuepress-plugin-flexsearch": "^0.3.0",
"vuepress-plugin-redirect": "^1.2.5",
"vuepress-plugin-typedoc": "^0.10.0",
"vuepress-theme-chartjs": "^0.2.0",
"webpack": "^4.46.0"
"vuepress-theme-chartjs": "^0.2.0"
},
"peerDependencies": {
"chart.js": ">=3.7.0"
Expand Down
21 changes: 13 additions & 8 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
const json = require('@rollup/plugin-json');
const resolve = require('@rollup/plugin-node-resolve').default;
const terser = require('@rollup/plugin-terser').default;
const {name, version, homepage, main, module: _module} = require('./package.json');
import {readFileSync} from 'fs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';

const {name, version, homepage, main, module, jsdelivr, license} = JSON.parse(readFileSync('./package.json'));

const banner = `/*!
* ${name} v${version}
* ${homepage}
* (c) ${(new Date(process.env.SOURCE_DATE_EPOCH ? (process.env.SOURCE_DATE_EPOCH * 1000) : new Date().getTime())).getFullYear()} chartjs-plugin-annotation Contributors
* Released under the MIT License
* Released under the ${license} license
*/`;

const input = 'src/index.js';
Expand All @@ -21,7 +23,8 @@ const globals = {
'chart.js/helpers': 'Chart.helpers'
};

module.exports = [
export default [
// UMD
{
input,
plugins: [
Expand All @@ -38,6 +41,7 @@ module.exports = [
},
external
},
// UMD min
{
input,
plugins: [
Expand All @@ -51,13 +55,14 @@ module.exports = [
],
output: {
name,
file: main.replace('.js', '.min.js'),
file: jsdelivr,
format: 'umd',
indent: false,
globals
},
external
},
// ESM
{
input: inputESM,
plugins: [
Expand All @@ -66,7 +71,7 @@ module.exports = [
],
output: {
name,
file: _module,
file: module,
banner,
format: 'esm',
indent: false
Expand Down
2 changes: 1 addition & 1 deletion scripts/docs-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ MODE=$2

TAG=$(tag_from_version "$VERSION" "$MODE")

sed -i -e "s/VERSION/$TAG/g" "docs/.vuepress/config.js"
sed -i -e "s/VERSION/$TAG/g" "docs/.vuepress/config.ts"
Loading