diff --git a/.eslintignore b/.eslintignore index 5f985010bc6..a261f291755 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1 @@ -dist/*.js +dist/* diff --git a/.eslintrc.yml b/.eslintrc.yml index 072c9ab2a5a..781df4c2df4 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -28,6 +28,7 @@ rules: no-empty-function: "off" no-use-before-define: ["error", { "functions": false }] # disable everything, except Rest/Spread Properties in ES2018 + es/no-import-meta: "off" es/no-async-iteration: "error" es/no-malformed-template-literals: "error" es/no-regexp-lookbehind-assertions: "error" diff --git a/.gitignore b/.gitignore index 112570e74f4..a03307d82f5 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ npm-debug.log* build/ # generated typedocs docs/api +docs/.vuepress/dist # Development .DS_Store diff --git a/.size-limit.js b/.size-limit.cjs similarity index 79% rename from .size-limit.js rename to .size-limit.cjs index 9fbf52b841e..e9ea99edd66 100644 --- a/.size-limit.js +++ b/.size-limit.cjs @@ -7,46 +7,40 @@ function modifyWebpackConfig(config) { module.exports = [ { path: 'dist/chart.js', - limit: '94.8 KB', - webpack: false, - running: false - }, - { - path: 'dist/chart.esm.js', limit: '75 KB', webpack: false, running: false }, { - path: 'dist/chart.esm.js', + path: 'dist/chart.js', limit: '34 KB', import: '{ Chart }', running: false, modifyWebpackConfig }, { - path: 'dist/chart.esm.js', + path: 'dist/chart.js', limit: '19.5 KB', import: '{ BarController, BubbleController, DoughnutController, LineController, PolarAreaController, PieController, RadarController, ScatterController }', running: false, modifyWebpackConfig }, { - path: 'dist/chart.esm.js', + path: 'dist/chart.js', limit: '14 KB', import: '{ ArcElement, LineElement, PointElement, BarElement }', running: false, modifyWebpackConfig }, { - path: 'dist/chart.esm.js', + path: 'dist/chart.js', limit: '27 KB', import: '{ Decimation, Filler, Legend, SubTitle, Title, Tooltip }', running: false, modifyWebpackConfig }, { - path: 'dist/chart.esm.js', + path: 'dist/chart.js', limit: '22 KB', import: '{ CategoryScale, LinearScale, LogarithmicScale, RadialLinearScale, TimeScale, TimeSeriesScale }', running: false, diff --git a/auto/auto.d.ts b/auto/auto.d.ts new file mode 100644 index 00000000000..566f043ac70 --- /dev/null +++ b/auto/auto.d.ts @@ -0,0 +1,4 @@ +import {Chart} from '../types'; + +export * from '../types'; +export default Chart; diff --git a/auto/auto.js b/auto/auto.js index 235580fef50..924a0f900ed 100644 --- a/auto/auto.js +++ b/auto/auto.js @@ -1 +1,6 @@ -module.exports = require('../dist/chart'); +import {Chart, registerables} from '../dist/chart.js'; + +Chart.register(...registerables); + +export * from '../dist/chart.js'; +export default Chart; diff --git a/auto/auto.mjs b/auto/auto.mjs deleted file mode 100644 index 95d0a9a92de..00000000000 --- a/auto/auto.mjs +++ /dev/null @@ -1,5 +0,0 @@ -import {Chart, registerables} from '../dist/chart.mjs'; - -Chart.register(...registerables); - -export default Chart; diff --git a/auto/auto.mts b/auto/auto.mts deleted file mode 100644 index f0bc380548f..00000000000 --- a/auto/auto.mts +++ /dev/null @@ -1,4 +0,0 @@ -import { Chart } from '../types/index.esm'; - -export * from '../types/index.esm'; -export default Chart; diff --git a/auto/package.json b/auto/package.json index 5f89c8f903f..b3e1dfbf5d6 100644 --- a/auto/package.json +++ b/auto/package.json @@ -1,8 +1,9 @@ { "name": "chart.js-auto", "private": true, - "description": "auto registering package", + "description": "Auto registering package. Exists to support bundlers without exports support such as webpack 4.", + "type": "module", "main": "auto.js", - "module": "auto.mjs", - "types": "auto.mts" + "exports": "./auto.js", + "types": "auto.d.ts" } diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.cjs similarity index 98% rename from docs/.vuepress/config.js rename to docs/.vuepress/config.cjs index bff3be11f95..4ada9ffd5f3 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.cjs @@ -33,7 +33,7 @@ module.exports = { [ 'vuepress-plugin-typedoc', { - entryPoints: ['../../types/index.esm.d.ts'], + entryPoints: ['../../types/index.d.ts'], hideInPageTOC: true, tsconfig: 'tsconfig.json', sidebar: { @@ -94,12 +94,10 @@ module.exports = { config.merge({ resolve: { alias: { - 'chart.js': path.resolve(__dirname, '../../dist/chart.mjs'), + 'chart.js': path.resolve(__dirname, '../../dist/chart.js'), } } }) - - config.module.rule('js').test(/\.m?jsx?$/) }, markdown: { extendMarkdown: md => { diff --git a/docs/getting-started/integration.md b/docs/getting-started/integration.md index 79fb100e9e2..e74aef8a69c 100644 --- a/docs/getting-started/integration.md +++ b/docs/getting-started/integration.md @@ -5,19 +5,12 @@ Chart.js can be integrated with plain JavaScript or with different module loader ## Script Tag ```html - + ``` -## Common JS - -```javascript -const Chart = require('chart.js'); -const myChart = new Chart(ctx, {...}); -``` - ## Bundlers (Webpack, Rollup, etc.) Chart.js 3 is tree-shakeable, so it is necessary to import and register the controllers, elements, scales and plugins you are going to use. @@ -96,6 +89,14 @@ And finally there is a separate path to do just the above for you, in one line: import Chart from 'chart.js/auto'; ``` +## CommonJS + +Because Chart.js is an ESM library, in CommonJS modules you should use a dynamic `import`: + +```javascript +const { Chart } = await import('chart.js'); +``` + ### Helper functions If you want to use the helper functions, you will need to import these separately from the helpers package and use them as stand-alone functions. @@ -123,10 +124,10 @@ const chart = new Chart(ctx, { ## Require JS -**Important:** RequireJS [can **not** load CommonJS module as is](https://requirejs.org/docs/commonjs.html#intro), so be sure to require one of the UMD builds instead (i.e. `dist/chart.js`, `dist/chart.min.js`, etc.). +**Important:** RequireJS can load only [AMD modules](https://requirejs.org/docs/whyamd.html), so be sure to require one of the UMD builds instead (i.e. `dist/chart.umd.js`). ```javascript -require(['path/to/chartjs/dist/chart.min.js'], function(Chart){ +require(['path/to/chartjs/dist/chart.umd.js'], function(Chart){ const myChart = new Chart(ctx, {...}); }); ``` diff --git a/docs/scripts/components.js b/docs/scripts/components.js index 9334eb2d72f..79f7841f3e7 100644 --- a/docs/scripts/components.js +++ b/docs/scripts/components.js @@ -1,3 +1,3 @@ // Add Chart components needed in samples here. // Usable through `components[name]`. -export {Tooltip} from '../../dist/chart.mjs'; +export {Tooltip} from '../../dist/chart.js'; diff --git a/docs/scripts/helpers.js b/docs/scripts/helpers.js index 39d60b68b1f..dc989488c92 100644 --- a/docs/scripts/helpers.js +++ b/docs/scripts/helpers.js @@ -1,3 +1,3 @@ // Add helpers needed in samples here. // Usable through `helpers[name]`. -export {color, getHoverColor, easingEffects} from '../../dist/helpers.mjs'; +export {color, getHoverColor, easingEffects} from '../../dist/helpers.js'; diff --git a/docs/scripts/register.js b/docs/scripts/register.js index 675f6443a40..e9b6a9f893f 100644 --- a/docs/scripts/register.js +++ b/docs/scripts/register.js @@ -1,4 +1,4 @@ -import {Chart, registerables} from '../../dist/chart.mjs'; +import {Chart, registerables} from '../../dist/chart.js'; import Log2Axis from './log2'; import './derived-bubble'; import analyzer from './analyzer'; diff --git a/docs/scripts/utils.js b/docs/scripts/utils.js index eab68e5f006..9cd3cfcf815 100644 --- a/docs/scripts/utils.js +++ b/docs/scripts/utils.js @@ -1,7 +1,7 @@ import colorLib from '@kurkle/color'; import {DateTime} from 'luxon'; import 'chartjs-adapter-luxon'; -import {valueOrDefault} from '../../dist/helpers.mjs'; +import {valueOrDefault} from '../../dist/helpers.js'; // Adapted from http://indiegamr.com/generate-repeatable-random-numbers-in-js/ var _seed = Date.now(); diff --git a/helpers/helpers.mts b/helpers/helpers.d.ts similarity index 100% rename from helpers/helpers.mts rename to helpers/helpers.d.ts diff --git a/helpers/helpers.js b/helpers/helpers.js index a762f589b4a..451fa58f739 100644 --- a/helpers/helpers.js +++ b/helpers/helpers.js @@ -1 +1 @@ -module.exports = require('..').helpers; +export * from '../dist/helpers.js'; diff --git a/helpers/helpers.mjs b/helpers/helpers.mjs deleted file mode 100644 index ca4eee5270d..00000000000 --- a/helpers/helpers.mjs +++ /dev/null @@ -1 +0,0 @@ -export * from '../dist/helpers.esm'; diff --git a/helpers/package.json b/helpers/package.json index 668b05e7007..5e45ceaa654 100644 --- a/helpers/package.json +++ b/helpers/package.json @@ -1,8 +1,9 @@ { "name": "chart.js-helpers", "private": true, - "description": "helper package", + "description": "Helpers package. Exists to support bundlers without exports support such as webpack 4.", + "type": "module", "main": "helpers.js", - "module": "helpers.mjs", - "types": "helpers.mts" -} \ No newline at end of file + "exports": "./helpers.js", + "types": "helpers.d.ts" +} diff --git a/karma.conf.js b/karma.conf.cjs similarity index 93% rename from karma.conf.js rename to karma.conf.cjs index 96cbc0e7a92..cde1d4faa88 100644 --- a/karma.conf.js +++ b/karma.conf.cjs @@ -1,9 +1,9 @@ -const jasmineSeedReporter = require('./test/seed-reporter'); +const jasmineSeedReporter = require('./test/seed-reporter.cjs'); const commonjs = require('@rollup/plugin-commonjs'); 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 builds = require('./rollup.config.cjs'); const yargs = require('yargs'); module.exports = function(karma) { @@ -18,9 +18,13 @@ 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 ? /chart\.js$/ : /chart\.min\.js$/; + const regex = /chart\.umd\.js$/; const build = builds.filter(v => v.output.file && v.output.file.match(regex))[0]; + if (karma.autoWatch) { + build.plugins.pop(); + } + if (args.coverage) { build.plugins = [ json(), @@ -87,14 +91,14 @@ module.exports = function(karma) { 'node_modules/moment-timezone/builds/moment-timezone-with-data.min.js', {pattern: 'test/index.js', watched: false}, {pattern: 'test/BasicChartWebWorker.js', included: false}, - {pattern: 'src/index.js', watched: false}, + {pattern: 'src/index.umd.js', watched: false}, 'node_modules/chartjs-adapter-moment/dist/chartjs-adapter-moment.js', {pattern: specPattern} ], preprocessors: { 'test/index.js': ['rollup'], - 'src/index.js': ['sources'] + 'src/index.umd.js': ['sources'] }, rollupPreprocessor: { diff --git a/package-lock.json b/package-lock.json index d2af668b5a2..601e16e38ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,7 +54,6 @@ "moment-timezone": "^0.5.34", "pixelmatch": "^5.2.1", "rollup": "^2.44.0", - "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-cleanup": "^3.2.1", "rollup-plugin-istanbul": "^3.0.0", "rollup-plugin-terser": "^7.0.2", @@ -15700,15 +15699,6 @@ "fsevents": "~2.3.2" } }, - "node_modules/rollup-plugin-analyzer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-analyzer/-/rollup-plugin-analyzer-4.0.0.tgz", - "integrity": "sha512-LL9GEt3bkXp6Wa19SNR5MWcvHNMvuTFYg+eYBZN2OIFhSWN+pEJUQXEKu5BsOeABob3x9PDaLKW7w5iOJnsESQ==", - "dev": true, - "engines": { - "node": ">=8.0.0" - } - }, "node_modules/rollup-plugin-cleanup": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/rollup-plugin-cleanup/-/rollup-plugin-cleanup-3.2.1.tgz", @@ -32864,12 +32854,6 @@ "fsevents": "~2.3.2" } }, - "rollup-plugin-analyzer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-analyzer/-/rollup-plugin-analyzer-4.0.0.tgz", - "integrity": "sha512-LL9GEt3bkXp6Wa19SNR5MWcvHNMvuTFYg+eYBZN2OIFhSWN+pEJUQXEKu5BsOeABob3x9PDaLKW7w5iOJnsESQ==", - "dev": true - }, "rollup-plugin-cleanup": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/rollup-plugin-cleanup/-/rollup-plugin-cleanup-3.2.1.tgz", diff --git a/package.json b/package.json index de4354c49a6..23cea7bcab8 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,16 @@ "description": "Simple HTML5 charts using the canvas element.", "version": "3.9.0", "license": "MIT", - "jsdelivr": "dist/chart.min.js", - "unpkg": "dist/chart.min.js", + "type": "module", + "jsdelivr": "dist/chart.umd.js", + "unpkg": "dist/chart.umd.js", "main": "dist/chart.js", - "module": "dist/chart.mjs", - "types": "types/index.esm.d.ts", + "exports": { + ".": "./dist/chart.js", + "./auto": "./auto/auto.js", + "./helpers": "./helpers/helpers.js" + }, + "types": "types/index.d.ts", "keywords": [ "canvas", "charts", @@ -33,20 +38,20 @@ "scripts": { "autobuild": "rollup -c -w", "build": "rollup -c", - "dev": "karma start --auto-watch --no-single-run --browsers chrome --grep", - "dev:ff": "karma start --auto-watch --no-single-run --browsers firefox --grep", + "dev": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers chrome --grep", + "dev:ff": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers firefox --grep", "docs": "npm run build && vuepress build docs --no-cache", "docs:dev": "npm run build && vuepress dev docs --no-cache", "lint-js": "eslint \"src/**/*.js\" \"test/**/*.js\" \"docs/**/*.js\"", "lint-md": "eslint \"**/*.md\"", "lint-tsc": "tsc", - "lint-types": "eslint \"types/**/*.ts\" && node -r esm types/tests/autogen.js && tsc -p types/tests/", + "lint-types": "eslint \"types/**/*.ts\" && npm run build && node types/tests/autogen.js && tsc -p types/tests/", "lint": "concurrently \"npm:lint-*\"", "test-size": "size-limit", "test": "npm run lint && npm run test-ci", "test-ci": "concurrently \"npm:test-ci-*\"", - "test-ci-karma": "cross-env NODE_ENV=test karma start --auto-watch --single-run --coverage --grep", - "test-ci-integration": "mocha --full-trace test/integration/*-test.js" + "test-ci-karma": "cross-env NODE_ENV=test karma start ./karma.conf.cjs --auto-watch --single-run --coverage --grep", + "test-ci-integration": "mocha --full-trace test/integration/*-test.cjs" }, "devDependencies": { "@kurkle/color": "^0.2.1", @@ -94,7 +99,6 @@ "moment-timezone": "^0.5.34", "pixelmatch": "^5.2.1", "rollup": "^2.44.0", - "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-cleanup": "^3.2.1", "rollup-plugin-istanbul": "^3.0.0", "rollup-plugin-terser": "^7.0.2", diff --git a/rollup.config.js b/rollup.config.cjs similarity index 52% rename from rollup.config.js rename to rollup.config.cjs index aeda6c0cd31..d2ca5d36ddd 100644 --- a/rollup.config.js +++ b/rollup.config.cjs @@ -1,12 +1,9 @@ -const analyze = require('rollup-plugin-analyzer'); const cleanup = require('rollup-plugin-cleanup'); const json = require('@rollup/plugin-json'); const resolve = require('@rollup/plugin-node-resolve').default; const terser = require('rollup-plugin-terser').terser; const pkg = require('./package.json'); -const input = 'src/index.js'; - const banner = `/*! * Chart.js v${pkg.version} * ${pkg.homepage} @@ -15,30 +12,10 @@ const banner = `/*! */`; module.exports = [ - // UMD builds - // dist/chart.min.js - // dist/chart.js - { - input, - plugins: [ - json(), - resolve(), - cleanup({ - comments: ['some', /__PURE__/], - sourcemap: true - }), - analyze({summaryOnly: true}) - ], - output: { - name: 'Chart', - file: 'dist/chart.js', - banner, - format: 'umd', - indent: false, - }, - }, + // UMD build + // dist/chart.umd.js { - input, + input: 'src/index.umd.js', plugins: [ json(), resolve(), @@ -50,45 +27,20 @@ module.exports = [ ], output: { name: 'Chart', - file: 'dist/chart.min.js', + file: 'dist/chart.umd.js', format: 'umd', indent: false, }, }, // ES6 builds - // dist/chart.mjs + // dist/chart.js // helpers/*.js { input: { - 'dist/chart': 'src/index.esm.js', + 'dist/chart': 'src/index.js', 'dist/helpers': 'src/helpers/index.js' }, - plugins: [ - json(), - resolve(), - cleanup({ - sourcemap: true - }), - ], - output: { - dir: './', - chunkFileNames: 'dist/chunks/[name].mjs', - entryFileNames: '[name].mjs', - banner, - format: 'esm', - indent: false, - }, - }, - - // Legacy ES6 builds for backwards compatibility. Remove for Chart.js 4.0 - // dist/chart.esm.js - // helpers/*.js - { - input: { - 'dist/chart.esm': 'src/index.esm.js', - 'dist/helpers.esm': 'src/helpers/index.js' - }, plugins: [ json(), resolve(), @@ -100,9 +52,10 @@ module.exports = [ output: { dir: './', chunkFileNames: 'dist/chunks/[name].js', + entryFileNames: '[name].js', banner, format: 'esm', indent: false, }, - }, + } ]; diff --git a/src/core/core.adapters.js b/src/core/core.adapters.js index 19eedbc721c..0859ea04d9d 100644 --- a/src/core/core.adapters.js +++ b/src/core/core.adapters.js @@ -5,7 +5,7 @@ */ /** - * @typedef { import("../../types/index.esm").ChartOptions } ChartOptions + * @typedef { import("../../types").ChartOptions } ChartOptions */ /** diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 359240de1cc..a6953ccb539 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -14,8 +14,8 @@ import {version} from '../../package.json'; import {debounce} from '../helpers/helpers.extras'; /** - * @typedef { import('../../types/index.esm').ChartEvent } ChartEvent - * @typedef { import("../../types/index.esm").Point } Point + * @typedef { import('../../types').ChartEvent } ChartEvent + * @typedef { import("../../types").Point } Point */ const KNOWN_POSITIONS = ['top', 'bottom', 'left', 'right', 'chartArea']; @@ -1240,10 +1240,10 @@ class Chart { /** * @param {ChartEvent} e - The event - * @param {import('../../types/index.esm').ActiveElement[]} lastActive - Previously active elements + * @param {import('../../types').ActiveElement[]} lastActive - Previously active elements * @param {boolean} inChartArea - Is the envent inside chartArea * @param {boolean} useFinalPosition - Should the evaluation be done with current or final (after animation) element positions - * @returns {import('../../types/index.esm').ActiveElement[]} - The active elements + * @returns {import('../../types').ActiveElement[]} - The active elements * @pravate */ _getActiveElements(e, lastActive, inChartArea, useFinalPosition) { diff --git a/src/core/core.interaction.js b/src/core/core.interaction.js index 5424c862ae1..776db328804 100644 --- a/src/core/core.interaction.js +++ b/src/core/core.interaction.js @@ -5,10 +5,10 @@ import {_isPointInArea} from '../helpers'; /** * @typedef { import("./core.controller").default } Chart - * @typedef { import("../../types/index.esm").ChartEvent } ChartEvent + * @typedef { import("../../types").ChartEvent } ChartEvent * @typedef {{axis?: string, intersect?: boolean, includeInvisible?: boolean}} InteractionOptions * @typedef {{datasetIndex: number, index: number, element: import("./core.element").default}} InteractionItem - * @typedef { import("../../types/index.esm").Point } Point + * @typedef { import("../../types").Point } Point */ /** diff --git a/src/core/core.plugins.js b/src/core/core.plugins.js index c1693ca1267..77aa6fb006e 100644 --- a/src/core/core.plugins.js +++ b/src/core/core.plugins.js @@ -3,7 +3,7 @@ import {callback as callCallback, isNullOrUndef, valueOrDefault} from '../helper /** * @typedef { import("./core.controller").default } Chart - * @typedef { import("../../types/index.esm").ChartEvent } ChartEvent + * @typedef { import("../../types").ChartEvent } ChartEvent * @typedef { import("../plugins/plugin.tooltip").default } Tooltip */ diff --git a/src/helpers/helpers.canvas.js b/src/helpers/helpers.canvas.js index 98e6705be2f..d79f6fb112f 100644 --- a/src/helpers/helpers.canvas.js +++ b/src/helpers/helpers.canvas.js @@ -6,7 +6,7 @@ import {PI, TAU, HALF_PI, QUARTER_PI, TWO_THIRDS_PI, RAD_PER_DEG} from './helper * necessary to avoid duplicates with `export * from './helpers`; see * https://github.com/microsoft/TypeScript/issues/46011 * @typedef { import("../core/core.controller").default } canvas.Chart - * @typedef { import("../../types/index.esm").Point } Point + * @typedef { import("../../types").Point } Point */ /** diff --git a/src/helpers/helpers.core.js b/src/helpers/helpers.core.js index ce15bc63108..1b1d1ff7810 100644 --- a/src/helpers/helpers.core.js +++ b/src/helpers/helpers.core.js @@ -369,7 +369,7 @@ export const setsEqual = (a, b) => { }; /** - * @param {import('../../types/index.esm').ChartEvent} e - The event + * @param {import('../../types').ChartEvent} e - The event * @returns {boolean} * @private */ diff --git a/src/helpers/helpers.dom.js b/src/helpers/helpers.dom.js index c4f54e00936..60ffb77d1ea 100644 --- a/src/helpers/helpers.dom.js +++ b/src/helpers/helpers.dom.js @@ -5,7 +5,7 @@ import {INFINITY} from './helpers.math'; * necessary to avoid duplicates with `export * from './helpers`; see * https://github.com/microsoft/TypeScript/issues/46011 * @typedef { import("../core/core.controller").default } dom.Chart - * @typedef { import('../../types/index.esm').ChartEvent } ChartEvent + * @typedef { import('../../types').ChartEvent } ChartEvent */ /** diff --git a/src/index.esm.js b/src/index.esm.js deleted file mode 100644 index 15865c36080..00000000000 --- a/src/index.esm.js +++ /dev/null @@ -1,25 +0,0 @@ -export * from './controllers'; -export * from './core'; -export * from './elements'; -export * from './platform'; -export * from './plugins'; -export * from './scales'; - -import * as controllers from './controllers'; -import * as elements from './elements'; -import * as plugins from './plugins'; -import * as scales from './scales'; - -export { - controllers, - elements, - plugins, - scales, -}; - -export const registerables = [ - controllers, - elements, - plugins, - scales, -]; diff --git a/src/index.js b/src/index.js index d3539015bf2..15865c36080 100644 --- a/src/index.js +++ b/src/index.js @@ -1,52 +1,25 @@ -// @ts-nocheck +export * from './controllers'; +export * from './core'; +export * from './elements'; +export * from './platform'; +export * from './plugins'; +export * from './scales'; -/** - * @namespace Chart - */ -import Chart from './core/core.controller'; - -import * as helpers from './helpers/index'; -import _adapters from './core/core.adapters'; -import Animation from './core/core.animation'; -import animator from './core/core.animator'; -import Animations from './core/core.animations'; import * as controllers from './controllers'; -import DatasetController from './core/core.datasetController'; -import Element from './core/core.element'; -import * as elements from './elements/index'; -import Interaction from './core/core.interaction'; -import layouts from './core/core.layouts'; -import * as platforms from './platform/index'; +import * as elements from './elements'; import * as plugins from './plugins'; -import registry from './core/core.registry'; -import Scale from './core/core.scale'; import * as scales from './scales'; -import Ticks from './core/core.ticks'; - -// Register built-ins -Chart.register(controllers, scales, elements, plugins); - -Chart.helpers = {...helpers}; -Chart._adapters = _adapters; -Chart.Animation = Animation; -Chart.Animations = Animations; -Chart.animator = animator; -Chart.controllers = registry.controllers.items; -Chart.DatasetController = DatasetController; -Chart.Element = Element; -Chart.elements = elements; -Chart.Interaction = Interaction; -Chart.layouts = layouts; -Chart.platforms = platforms; -Chart.Scale = Scale; -Chart.Ticks = Ticks; - -// Compatibility with ESM extensions -Object.assign(Chart, controllers, scales, elements, plugins, platforms); -Chart.Chart = Chart; -if (typeof window !== 'undefined') { - window.Chart = Chart; -} +export { + controllers, + elements, + plugins, + scales, +}; -export default Chart; +export const registerables = [ + controllers, + elements, + plugins, + scales, +]; diff --git a/src/index.umd.js b/src/index.umd.js new file mode 100644 index 00000000000..d3539015bf2 --- /dev/null +++ b/src/index.umd.js @@ -0,0 +1,52 @@ +// @ts-nocheck + +/** + * @namespace Chart + */ +import Chart from './core/core.controller'; + +import * as helpers from './helpers/index'; +import _adapters from './core/core.adapters'; +import Animation from './core/core.animation'; +import animator from './core/core.animator'; +import Animations from './core/core.animations'; +import * as controllers from './controllers'; +import DatasetController from './core/core.datasetController'; +import Element from './core/core.element'; +import * as elements from './elements/index'; +import Interaction from './core/core.interaction'; +import layouts from './core/core.layouts'; +import * as platforms from './platform/index'; +import * as plugins from './plugins'; +import registry from './core/core.registry'; +import Scale from './core/core.scale'; +import * as scales from './scales'; +import Ticks from './core/core.ticks'; + +// Register built-ins +Chart.register(controllers, scales, elements, plugins); + +Chart.helpers = {...helpers}; +Chart._adapters = _adapters; +Chart.Animation = Animation; +Chart.Animations = Animations; +Chart.animator = animator; +Chart.controllers = registry.controllers.items; +Chart.DatasetController = DatasetController; +Chart.Element = Element; +Chart.elements = elements; +Chart.Interaction = Interaction; +Chart.layouts = layouts; +Chart.platforms = platforms; +Chart.Scale = Scale; +Chart.Ticks = Ticks; + +// Compatibility with ESM extensions +Object.assign(Chart, controllers, scales, elements, plugins, platforms); +Chart.Chart = Chart; + +if (typeof window !== 'undefined') { + window.Chart = Chart; +} + +export default Chart; diff --git a/src/plugins/plugin.filler/filler.options.js b/src/plugins/plugin.filler/filler.options.js index bc22cec888d..70b740d7785 100644 --- a/src/plugins/plugin.filler/filler.options.js +++ b/src/plugins/plugin.filler/filler.options.js @@ -3,8 +3,8 @@ import {isObject, isFinite, valueOrDefault} from '../../helpers/helpers.core'; /** * @typedef { import('../../core/core.scale').default } Scale * @typedef { import('../../elements/element.line').default } LineElement - * @typedef { import('../../../types/index.esm').FillTarget } FillTarget - * @typedef { import('../../../types/index.esm').ComplexFillTarget } ComplexFillTarget + * @typedef { import('../../../types').FillTarget } FillTarget + * @typedef { import('../../../types').ComplexFillTarget } ComplexFillTarget */ export function _resolveTarget(sources, index, propagate) { diff --git a/src/plugins/plugin.legend.js b/src/plugins/plugin.legend.js index 936111d848f..c4d7564a55b 100644 --- a/src/plugins/plugin.legend.js +++ b/src/plugins/plugin.legend.js @@ -10,7 +10,7 @@ import { import {_toLeftRightCenter, _alignStartEnd, _textX} from '../helpers/helpers.extras'; import {toTRBLCorners} from '../helpers/helpers.options'; /** - * @typedef { import("../../types/index.esm").ChartEvent } ChartEvent + * @typedef { import("../../types").ChartEvent } ChartEvent */ const getBoxSize = (labelOpts, fontSize) => { diff --git a/src/plugins/plugin.tooltip.js b/src/plugins/plugin.tooltip.js index bc168984809..77d40be5516 100644 --- a/src/plugins/plugin.tooltip.js +++ b/src/plugins/plugin.tooltip.js @@ -9,8 +9,8 @@ import {createContext, drawPoint} from '../helpers'; /** * @typedef { import("../platform/platform.base").Chart } Chart - * @typedef { import("../../types/index.esm").ChartEvent } ChartEvent - * @typedef { import("../../types/index.esm").ActiveElement } ActiveElement + * @typedef { import("../../types").ChartEvent } ChartEvent + * @typedef { import("../../types").ActiveElement } ActiveElement */ const positioners = { diff --git a/test/BasicChartWebWorker.js b/test/BasicChartWebWorker.js index ca267713eb6..900084ffe2a 100644 --- a/test/BasicChartWebWorker.js +++ b/test/BasicChartWebWorker.js @@ -6,7 +6,7 @@ // Sends messages with data of types: { type: 'success' } | { type: 'error', errorMessage: string } // eslint-disable-next-line no-undef -importScripts('../src/chart.js'); +importScripts('../src/chart.umd.js'); onmessage = function(event) { try { diff --git a/test/integration/integration-test.js b/test/integration/integration-test.cjs similarity index 100% rename from test/integration/integration-test.js rename to test/integration/integration-test.cjs diff --git a/test/integration/node/package.json b/test/integration/node/package.json index 6754a4f3bbd..5be41d8d74b 100644 --- a/test/integration/node/package.json +++ b/test/integration/node/package.json @@ -1,11 +1,11 @@ { "private": true, "description": "chart.js should work in Node", + "type": "module", "scripts": { - "test": "npm run test-cjs", - "test-cjs": "node test.cjs", - "test-mjs": "node test.mjs", - "TODO": "test-mjs should be enambled for chart.js v4" + "test": "npm run test-mjs && npm run test-cjs", + "test-mjs": "node test.js", + "test-cjs": "node test.cjs" }, "dependencies": { "chart.js": "file:../package.tgz" diff --git a/test/integration/node/test.cjs b/test/integration/node/test.cjs index 2c5219c7096..94f86f2214f 100644 --- a/test/integration/node/test.cjs +++ b/test/integration/node/test.cjs @@ -1,7 +1,10 @@ -const Chart = require('chart.js'); -const valueOrDefault = Chart.helpers.valueOrDefault; - -Chart.register({ - id: 'TEST_PLUGIN', - dummyValue: valueOrDefault(0, 1) +/* eslint-disable es/no-dynamic-import */ +Promise.all([ + import('chart.js'), + import('chart.js/helpers') +]).then(([{Chart}, {valueOrDefault}]) => { + Chart.register({ + id: 'TEST_PLUGIN', + dummyValue: valueOrDefault(0, 1) + }); }); diff --git a/test/integration/node/test.mjs b/test/integration/node/test.js similarity index 100% rename from test/integration/node/test.mjs rename to test/integration/node/test.js diff --git a/test/seed-reporter.js b/test/seed-reporter.cjs similarity index 100% rename from test/seed-reporter.js rename to test/seed-reporter.cjs diff --git a/tsconfig.json b/tsconfig.json index bff8bcec762..9a2e9d66be3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,7 @@ }, "typedocOptions": { "name": "Chart.js", - "entryPoints": ["types/index.esm.d.ts"], + "entryPoints": ["types/index.d.ts"], "readme": "none", "excludeExternals": true, "includeVersion": true, diff --git a/types/adapters.d.ts b/types/adapters.d.ts index cae40966ba0..7e3e63c8ebe 100644 --- a/types/adapters.d.ts +++ b/types/adapters.d.ts @@ -1,4 +1,4 @@ -import type { ChartOptions } from './index.esm'; +import type { ChartOptions } from '.'; export type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'; diff --git a/types/animation.d.ts b/types/animation.d.ts index b83204124f8..0aece8eae53 100644 --- a/types/animation.d.ts +++ b/types/animation.d.ts @@ -1,4 +1,4 @@ -import { Chart } from './index.esm'; +import { Chart } from '.'; import { AnyObject } from './basic'; export class Animation { diff --git a/types/helpers/helpers.canvas.d.ts b/types/helpers/helpers.canvas.d.ts index e6961af9355..4adb7ee63f2 100644 --- a/types/helpers/helpers.canvas.d.ts +++ b/types/helpers/helpers.canvas.d.ts @@ -1,4 +1,4 @@ -import { PointStyle } from '../index.esm'; +import { PointStyle } from '..'; import { Color } from '../color'; import { ChartArea, RoundedRect } from '../geometric'; import { CanvasFontSpec } from './helpers.options'; diff --git a/types/helpers/helpers.dom.d.ts b/types/helpers/helpers.dom.d.ts index 73864314086..a595b6b5b7e 100644 --- a/types/helpers/helpers.dom.d.ts +++ b/types/helpers/helpers.dom.d.ts @@ -1,4 +1,4 @@ -import { ChartEvent } from '../index.esm'; +import { ChartEvent } from '..'; export function getMaximumSize(node: HTMLElement, width?: number, height?: number, aspectRatio?: number): { width: number, height: number }; export function getRelativePosition( diff --git a/types/helpers/helpers.easing.d.ts b/types/helpers/helpers.easing.d.ts index b86d6532a51..682a5d05abd 100644 --- a/types/helpers/helpers.easing.d.ts +++ b/types/helpers/helpers.easing.d.ts @@ -1,4 +1,4 @@ -import { EasingFunction } from '../index.esm'; +import { EasingFunction } from '..'; export type EasingFunctionSignature = (t: number) => number; diff --git a/types/helpers/helpers.options.d.ts b/types/helpers/helpers.options.d.ts index 0bd783fa970..b622e71e86a 100644 --- a/types/helpers/helpers.options.d.ts +++ b/types/helpers/helpers.options.d.ts @@ -1,5 +1,5 @@ import { TRBL, TRBLCorners } from '../geometric'; -import { FontSpec } from '../index.esm'; +import { FontSpec } from '..'; export interface CanvasFontSpec extends FontSpec { string: string; diff --git a/types/index.esm.d.ts b/types/index.d.ts similarity index 100% rename from types/index.esm.d.ts rename to types/index.d.ts diff --git a/types/tests/animation.ts b/types/tests/animation.ts index bc9ff433efc..6e38e68eac6 100644 --- a/types/tests/animation.ts +++ b/types/tests/animation.ts @@ -1,4 +1,4 @@ -import { Chart } from '../index.esm'; +import { Chart } from '..'; const chart = new Chart('id', { type: 'bar', diff --git a/types/tests/autogen.js b/types/tests/autogen.js index 6b377044459..584a33636f1 100644 --- a/types/tests/autogen.js +++ b/types/tests/autogen.js @@ -1,6 +1,9 @@ import * as fs from 'fs'; import * as path from 'path'; -import * as helpers from '../../src/helpers/index.js'; +import { fileURLToPath } from 'url'; +import * as helpers from '../../dist/helpers.js'; + +const __dirname = fileURLToPath(new URL('.', import.meta.url)); let fd; diff --git a/types/tests/chart_types.ts b/types/tests/chart_types.ts index f05bda4da86..32831901e2c 100644 --- a/types/tests/chart_types.ts +++ b/types/tests/chart_types.ts @@ -1,4 +1,4 @@ -import { Chart } from '../index.esm'; +import { Chart } from '..'; const chart = new Chart('chart', { type: 'bar', diff --git a/types/tests/controllers/bubble_chart_options.ts b/types/tests/controllers/bubble_chart_options.ts index e036037e6c6..5924dd5f956 100644 --- a/types/tests/controllers/bubble_chart_options.ts +++ b/types/tests/controllers/bubble_chart_options.ts @@ -1,4 +1,4 @@ -import { Chart, ChartOptions } from '../../index.esm'; +import { Chart, ChartOptions } from '../..'; const chart = new Chart('test', { type: 'bubble', diff --git a/types/tests/controllers/doughnut_meta_total.ts b/types/tests/controllers/doughnut_meta_total.ts index da94fa0d8b0..76eb6eb6fb1 100644 --- a/types/tests/controllers/doughnut_meta_total.ts +++ b/types/tests/controllers/doughnut_meta_total.ts @@ -1,4 +1,4 @@ -import { Chart, ChartMeta, Element } from '../../index.esm'; +import { Chart, ChartMeta, Element } from '../..'; const chart = new Chart('id', { type: 'doughnut', diff --git a/types/tests/controllers/doughnut_offset.ts b/types/tests/controllers/doughnut_offset.ts index 58f7546bde2..cf2d0694386 100644 --- a/types/tests/controllers/doughnut_offset.ts +++ b/types/tests/controllers/doughnut_offset.ts @@ -1,4 +1,4 @@ -import { Chart, ChartMeta, Element } from '../../index.esm'; +import { Chart, ChartMeta, Element } from '../..'; const chart = new Chart('id', { type: 'doughnut', diff --git a/types/tests/controllers/doughnut_outer_radius.ts b/types/tests/controllers/doughnut_outer_radius.ts index e1074f39cad..e72d309c2aa 100644 --- a/types/tests/controllers/doughnut_outer_radius.ts +++ b/types/tests/controllers/doughnut_outer_radius.ts @@ -1,4 +1,4 @@ -import { Chart } from '../../index.esm'; +import { Chart } from '../..'; const chart = new Chart('id', { type: 'doughnut', diff --git a/types/tests/controllers/line_scriptable_parsed_data.ts b/types/tests/controllers/line_scriptable_parsed_data.ts index da88d0ec2b5..7a726da37ce 100644 --- a/types/tests/controllers/line_scriptable_parsed_data.ts +++ b/types/tests/controllers/line_scriptable_parsed_data.ts @@ -1,4 +1,4 @@ -import { Chart } from '../../index.esm'; +import { Chart } from '../..'; const chart = new Chart('id', { type: 'line', diff --git a/types/tests/controllers/line_segments.ts b/types/tests/controllers/line_segments.ts index 9e99e3d21cd..5d07063a951 100644 --- a/types/tests/controllers/line_segments.ts +++ b/types/tests/controllers/line_segments.ts @@ -1,4 +1,4 @@ -import { Chart } from '../../index.esm'; +import { Chart } from '../..'; const chart = new Chart('id', { type: 'line', diff --git a/types/tests/controllers/line_span_gaps.ts b/types/tests/controllers/line_span_gaps.ts index 040c9a99c03..0025641bde4 100644 --- a/types/tests/controllers/line_span_gaps.ts +++ b/types/tests/controllers/line_span_gaps.ts @@ -1,4 +1,4 @@ -import { Chart } from '../../index.esm'; +import { Chart } from '../..'; const chart = new Chart('id', { type: 'line', diff --git a/types/tests/controllers/line_styling_array.ts b/types/tests/controllers/line_styling_array.ts index 3b6c6733c45..daf2b7be74a 100644 --- a/types/tests/controllers/line_styling_array.ts +++ b/types/tests/controllers/line_styling_array.ts @@ -1,4 +1,4 @@ -import { Chart } from '../../index.esm'; +import { Chart } from '../..'; const chart = new Chart('id', { type: 'line', diff --git a/types/tests/controllers/radar_dataset_indexable_options.ts b/types/tests/controllers/radar_dataset_indexable_options.ts index 0c66f23f6cb..7ef75361976 100644 --- a/types/tests/controllers/radar_dataset_indexable_options.ts +++ b/types/tests/controllers/radar_dataset_indexable_options.ts @@ -1,4 +1,4 @@ -import { Chart, ChartOptions } from '../../index.esm'; +import { Chart, ChartOptions } from '../..'; const chart = new Chart('test', { type: 'radar', diff --git a/types/tests/data_types.ts b/types/tests/data_types.ts index 1740d8e6690..0e6a2d87f79 100644 --- a/types/tests/data_types.ts +++ b/types/tests/data_types.ts @@ -1,4 +1,4 @@ -import { Chart } from '../index.esm'; +import { Chart } from '..'; const chart = new Chart('chart', { type: 'bar', diff --git a/types/tests/dataset_null_data.ts b/types/tests/dataset_null_data.ts index ae13c6a2100..bb86a0aaec3 100644 --- a/types/tests/dataset_null_data.ts +++ b/types/tests/dataset_null_data.ts @@ -1,4 +1,4 @@ -import { ChartDataset } from '../index.esm'; +import { ChartDataset } from '..'; const dataset: ChartDataset = { data: [10, null, 20], diff --git a/types/tests/defaults.ts b/types/tests/defaults.ts index a3e8e96f5fe..c4c591000ee 100644 --- a/types/tests/defaults.ts +++ b/types/tests/defaults.ts @@ -1,4 +1,4 @@ -import { Chart } from '../index.esm'; +import { Chart } from '..'; Chart.defaults.scales.time.time.minUnit = 'day'; diff --git a/types/tests/elements/scriptable_element_options.ts b/types/tests/elements/scriptable_element_options.ts index c81892d7910..791684c64b1 100644 --- a/types/tests/elements/scriptable_element_options.ts +++ b/types/tests/elements/scriptable_element_options.ts @@ -1,4 +1,4 @@ -import { Chart } from '../../index.esm'; +import { Chart } from '../..'; const chart = new Chart('id', { type: 'line', diff --git a/types/tests/extensions/plugin.ts b/types/tests/extensions/plugin.ts index fcb0bd0e9b1..b0a89c5b08d 100644 --- a/types/tests/extensions/plugin.ts +++ b/types/tests/extensions/plugin.ts @@ -1,4 +1,4 @@ -import { Chart } from '../../index.esm'; +import { Chart } from '../..'; Chart.register({ id: 'my-plugin', diff --git a/types/tests/extensions/scale.ts b/types/tests/extensions/scale.ts index fdf1c89e4d5..0b6a10dcc13 100644 --- a/types/tests/extensions/scale.ts +++ b/types/tests/extensions/scale.ts @@ -1,5 +1,5 @@ import { AnyObject } from '../../basic'; -import { CartesianScaleOptions, Chart, Scale } from '../../index.esm'; +import { CartesianScaleOptions, Chart, Scale } from '../..'; export type TestScaleOptions = CartesianScaleOptions & { testOption?: boolean @@ -17,7 +17,7 @@ export class TestScale extends Sc } } -declare module '../../index.esm' { +declare module '../..' { interface CartesianScaleTypeRegistry { test: { options: TestScaleOptions diff --git a/types/tests/interaction.ts b/types/tests/interaction.ts index e5df1da1995..3450bbfe0ec 100644 --- a/types/tests/interaction.ts +++ b/types/tests/interaction.ts @@ -1,6 +1,6 @@ import { Chart, ChartData, ChartConfiguration, Element -} from '../index.esm'; +} from '..'; const data: ChartData<'line'> = { datasets: [] }; const chartItem = 'item'; diff --git a/types/tests/layout/position.ts b/types/tests/layout/position.ts index 87f249e27d3..544ed4f3ea8 100644 --- a/types/tests/layout/position.ts +++ b/types/tests/layout/position.ts @@ -1,4 +1,4 @@ -import { LayoutPosition } from '../../index.esm'; +import { LayoutPosition } from '../..'; const left: LayoutPosition = 'left'; const right: LayoutPosition = 'right'; diff --git a/types/tests/options.ts b/types/tests/options.ts index 0aab0f0f7cb..2ec8b895cfe 100644 --- a/types/tests/options.ts +++ b/types/tests/options.ts @@ -1,4 +1,4 @@ -import { Chart } from '../index.esm'; +import { Chart } from '..'; const chart = new Chart('test', { type: 'bar', diff --git a/types/tests/overrides.ts b/types/tests/overrides.ts index 8c2e02d6cc9..1e184e561ee 100644 --- a/types/tests/overrides.ts +++ b/types/tests/overrides.ts @@ -1,4 +1,4 @@ -import { Chart } from '../index.esm'; +import { Chart } from '..'; Chart.overrides.bar.scales.x.type = 'time'; diff --git a/types/tests/parsed.data.type.ts b/types/tests/parsed.data.type.ts index c5476eaae39..54b207a4beb 100644 --- a/types/tests/parsed.data.type.ts +++ b/types/tests/parsed.data.type.ts @@ -1,4 +1,4 @@ -import { ParsedDataType } from '../index.esm'; +import { ParsedDataType } from '..'; interface test { pie: ParsedDataType<'pie'>, diff --git a/types/tests/plugins/defaults.ts b/types/tests/plugins/defaults.ts index ec54b34ffa1..9ca1edea64f 100644 --- a/types/tests/plugins/defaults.ts +++ b/types/tests/plugins/defaults.ts @@ -1,4 +1,4 @@ -import { defaults } from '../../index.esm'; +import { defaults } from '../..'; // https://github.com/chartjs/Chart.js/issues/8711 const original = defaults.plugins.legend.labels.generateLabels; diff --git a/types/tests/plugins/plugin.decimation/decimation_algorithm.ts b/types/tests/plugins/plugin.decimation/decimation_algorithm.ts index 978764bde90..a6659bac7c6 100644 --- a/types/tests/plugins/plugin.decimation/decimation_algorithm.ts +++ b/types/tests/plugins/plugin.decimation/decimation_algorithm.ts @@ -1,4 +1,4 @@ -import { Chart, DecimationAlgorithm } from '../../../index.esm'; +import { Chart, DecimationAlgorithm } from '../../..'; const chart = new Chart('id', { type: 'bubble', diff --git a/types/tests/plugins/plugin.filler/fill_target_true.ts b/types/tests/plugins/plugin.filler/fill_target_true.ts index d9dc21061f0..3768ddedae8 100644 --- a/types/tests/plugins/plugin.filler/fill_target_true.ts +++ b/types/tests/plugins/plugin.filler/fill_target_true.ts @@ -1,4 +1,4 @@ -import { ChartDataset } from '../../../index.esm'; +import { ChartDataset } from '../../..'; const dataset: ChartDataset = { data: [], diff --git a/types/tests/plugins/plugin.tooltip/chart.tooltip.ts b/types/tests/plugins/plugin.tooltip/chart.tooltip.ts index 66c824412d6..56b37f29571 100644 --- a/types/tests/plugins/plugin.tooltip/chart.tooltip.ts +++ b/types/tests/plugins/plugin.tooltip/chart.tooltip.ts @@ -1,4 +1,4 @@ -import { Chart } from '../../../index.esm'; +import { Chart } from '../../..'; const chart = new Chart('id', { type: 'line', diff --git a/types/tests/plugins/plugin.tooltip/tooltip_dataset_type.ts b/types/tests/plugins/plugin.tooltip/tooltip_dataset_type.ts index 989a7cc45f5..343828d8dd5 100644 --- a/types/tests/plugins/plugin.tooltip/tooltip_dataset_type.ts +++ b/types/tests/plugins/plugin.tooltip/tooltip_dataset_type.ts @@ -1,4 +1,4 @@ -import { Chart } from '../../../index.esm'; +import { Chart } from '../../..'; const chart = new Chart('id', { type: 'line', diff --git a/types/tests/plugins/plugin.tooltip/tooltip_parsed_data.ts b/types/tests/plugins/plugin.tooltip/tooltip_parsed_data.ts index 93b7a9004ba..d7fb45959b6 100644 --- a/types/tests/plugins/plugin.tooltip/tooltip_parsed_data.ts +++ b/types/tests/plugins/plugin.tooltip/tooltip_parsed_data.ts @@ -1,4 +1,4 @@ -import { Chart } from '../../../index.esm'; +import { Chart } from '../../..'; const chart = new Chart('id', { type: 'bar', diff --git a/types/tests/plugins/plugin.tooltip/tooltip_parsed_data_chart_defaults.ts b/types/tests/plugins/plugin.tooltip/tooltip_parsed_data_chart_defaults.ts index 694943e6094..d1488b681cf 100644 --- a/types/tests/plugins/plugin.tooltip/tooltip_parsed_data_chart_defaults.ts +++ b/types/tests/plugins/plugin.tooltip/tooltip_parsed_data_chart_defaults.ts @@ -1,4 +1,4 @@ -import { Chart } from '../../../index.esm'; +import { Chart } from '../../..'; Chart.overrides.bubble.plugins.tooltip.callbacks.label = (item) => { const { x, y, _custom: r } = item.parsed; diff --git a/types/tests/plugins/plugin.tooltip/tooltip_scriptable_background_color.ts b/types/tests/plugins/plugin.tooltip/tooltip_scriptable_background_color.ts index a55d4454781..36c54d7e0f6 100644 --- a/types/tests/plugins/plugin.tooltip/tooltip_scriptable_background_color.ts +++ b/types/tests/plugins/plugin.tooltip/tooltip_scriptable_background_color.ts @@ -1,4 +1,4 @@ -import { Chart } from '../../../index.esm'; +import { Chart } from '../../..'; const chart = new Chart('id', { type: 'bar', diff --git a/types/tests/register.ts b/types/tests/register.ts index 7256ef8b374..49979d7a808 100644 --- a/types/tests/register.ts +++ b/types/tests/register.ts @@ -24,7 +24,7 @@ import { Title, SubTitle, Tooltip -} from '../index.esm'; +} from '..'; Chart.register( ArcElement, diff --git a/types/tests/scales/chart_options.ts b/types/tests/scales/chart_options.ts index a0b02d79af4..c097601a9fd 100644 --- a/types/tests/scales/chart_options.ts +++ b/types/tests/scales/chart_options.ts @@ -1,4 +1,4 @@ -import { ChartOptions } from '../../index.esm'; +import { ChartOptions } from '../..'; const chartOptions: ChartOptions<'line'> = { scales: { diff --git a/types/tests/scales/options.ts b/types/tests/scales/options.ts index cc1dc9015d9..a521f015036 100644 --- a/types/tests/scales/options.ts +++ b/types/tests/scales/options.ts @@ -1,4 +1,4 @@ -import { Chart, ScaleOptions } from '../../index.esm'; +import { Chart, ScaleOptions } from '../..'; const chart = new Chart('test', { type: 'bar', diff --git a/types/tests/scales/time_string_max.ts b/types/tests/scales/time_string_max.ts index 530b1c548e3..9c1c38bf45c 100644 --- a/types/tests/scales/time_string_max.ts +++ b/types/tests/scales/time_string_max.ts @@ -1,4 +1,4 @@ -import { Chart } from '../../index.esm'; +import { Chart } from '../..'; const chart = new Chart('id', { type: 'line', diff --git a/types/tests/scriptable.ts b/types/tests/scriptable.ts index db72edb21ff..bf9cec80526 100644 --- a/types/tests/scriptable.ts +++ b/types/tests/scriptable.ts @@ -1,4 +1,4 @@ -import { ChartType, Scriptable, ScriptableContext } from '../index.esm'; +import { ChartType, Scriptable, ScriptableContext } from '..'; interface test { pie?: Scriptable>, diff --git a/types/tests/scriptable_core_chart_options.ts b/types/tests/scriptable_core_chart_options.ts index 2c81f592e6c..3e2115f655f 100644 --- a/types/tests/scriptable_core_chart_options.ts +++ b/types/tests/scriptable_core_chart_options.ts @@ -1,4 +1,4 @@ -import { ChartConfiguration } from '../index.esm'; +import { ChartConfiguration } from '..'; const getConfig = (): ChartConfiguration<'bar'> => { return { diff --git a/types/tests/test_instance_assignment.ts b/types/tests/test_instance_assignment.ts index 044f53f7cfb..ea3951d2ead 100644 --- a/types/tests/test_instance_assignment.ts +++ b/types/tests/test_instance_assignment.ts @@ -1,4 +1,4 @@ -import { Chart } from '../index.esm'; +import { Chart } from '..'; const chart = new Chart('id', { type: 'scatter', diff --git a/types/tests/tsconfig.json b/types/tests/tsconfig.json index 9bbed3c55d6..a8494a0a8ae 100644 --- a/types/tests/tsconfig.json +++ b/types/tests/tsconfig.json @@ -8,6 +8,6 @@ }, "include": [ "./**/*.ts", - "../index.esm.d.ts" + "../index.d.ts" ] }