Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 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
});
7 changes: 4 additions & 3 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 Down
42 changes: 19 additions & 23 deletions package-lock.json

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

31 changes: 17 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@
"version": "2.1.0",
"author": "Evert Timberg <[email protected]>",
"license": "MIT",
"main": "dist/chartjs-plugin-annotation.js",
"module": "dist/chartjs-plugin-annotation.esm.js",
"type": "module",
"main": "dist/chartjs-plugin-annotation.esm.js",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to support chart.js v3 on node/commonjs with these later annotation plugin versions, this needs to be umd build with .cjs extension

Something like I did in autocolors: https://github.com/kurkle/chartjs-plugin-autocolors/blob/main/package.json

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok Let me update in next hours

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kurkle updated as suggested

"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.min.js"
},
"types": "types/index.d.ts",
"repository": {
"type": "git",
Expand All @@ -18,30 +25,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-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,10 +57,10 @@
"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",
Expand All @@ -72,8 +76,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
18 changes: 10 additions & 8 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
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, license} = JSON.parse(readFileSync('./package.json'));

const banner = `/*!
* ${name} v${version}
Expand All @@ -21,7 +23,7 @@ const globals = {
'chart.js/helpers': 'Chart.helpers'
};

module.exports = [
export default [
{
input,
plugins: [
Expand All @@ -30,7 +32,7 @@ module.exports = [
],
output: {
name,
file: main,
file: 'dist/chartjs-plugin-annotation.js',
banner,
format: 'umd',
indent: false,
Expand All @@ -51,7 +53,7 @@ module.exports = [
],
output: {
name,
file: main.replace('.js', '.min.js'),
file: 'dist/chartjs-plugin-annotation.min.js',
format: 'umd',
indent: false,
globals
Expand All @@ -66,7 +68,7 @@ module.exports = [
],
output: {
name,
file: _module,
file: 'dist/chartjs-plugin-annotation.esm.js',
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"
13 changes: 7 additions & 6 deletions test/integration/integration-test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'use strict';

const os = require('os');
const fs = require('fs-extra');
const path = require('path');
const childProcess = require('child_process');
import os from 'os';
import fs from 'fs-extra';
import path from 'path';
import childProcess from 'child_process';
import process from 'process';

const {describe, it} = require('mocha');
import {describe, it} from 'mocha';

function exec(command, options = {}) {
const output = childProcess.execSync(command, {
Expand All @@ -28,7 +29,7 @@ describe('Integration Tests', () => {
);

function testOnNodeProject(projectName) {
const projectPath = path.join(__dirname, projectName);
const projectPath = path.join(process.cwd(), 'test', 'integration', projectName);

const packageJSONPath = path.join(projectPath, 'package.json');
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf-8'));
Expand Down
2 changes: 1 addition & 1 deletion test/seed-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ const SeedReporter = function(baseReporterDecorator) {
};
};

module.exports = {
export default {
'reporter:jasmine-seed': ['type', SeedReporter]
};