]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
feat: add ESM support (#10525)
authorDan Onoshko <danon0404@gmail.com>
Thu, 4 Aug 2022 22:43:26 +0000 (05:43 +0700)
committerGitHub <noreply@github.com>
Thu, 4 Aug 2022 22:43:26 +0000 (18:43 -0400)
* feat: add ESM support

* build: rename UMD bundle

* chore: edit supbackages description

* style: disable es/no-import-meta linter rule

* test: dynamic import in cjs module

* docs: edit integrations page

* docs: review fixes

* chore: remove useless regex in webpack config

* ci: test size-limit only for ESM bundle

89 files changed:
.eslintignore
.eslintrc.yml
.gitignore
.size-limit.cjs [moved from .size-limit.js with 79% similarity]
auto/auto.d.ts [new file with mode: 0644]
auto/auto.js
auto/auto.mjs [deleted file]
auto/auto.mts [deleted file]
auto/package.json
docs/.vuepress/config.cjs [moved from docs/.vuepress/config.js with 98% similarity]
docs/getting-started/integration.md
docs/scripts/components.js
docs/scripts/helpers.js
docs/scripts/register.js
docs/scripts/utils.js
helpers/helpers.d.ts [moved from helpers/helpers.mts with 100% similarity]
helpers/helpers.js
helpers/helpers.mjs [deleted file]
helpers/package.json
karma.conf.cjs [moved from karma.conf.js with 93% similarity]
package-lock.json
package.json
rollup.config.cjs [moved from rollup.config.js with 52% similarity]
src/core/core.adapters.js
src/core/core.controller.js
src/core/core.interaction.js
src/core/core.plugins.js
src/helpers/helpers.canvas.js
src/helpers/helpers.core.js
src/helpers/helpers.dom.js
src/index.esm.js [deleted file]
src/index.js
src/index.umd.js [new file with mode: 0644]
src/plugins/plugin.filler/filler.options.js
src/plugins/plugin.legend.js
src/plugins/plugin.tooltip.js
test/BasicChartWebWorker.js
test/integration/integration-test.cjs [moved from test/integration/integration-test.js with 100% similarity]
test/integration/node/package.json
test/integration/node/test.cjs
test/integration/node/test.js [moved from test/integration/node/test.mjs with 100% similarity]
test/seed-reporter.cjs [moved from test/seed-reporter.js with 100% similarity]
tsconfig.json
types/adapters.d.ts
types/animation.d.ts
types/helpers/helpers.canvas.d.ts
types/helpers/helpers.dom.d.ts
types/helpers/helpers.easing.d.ts
types/helpers/helpers.options.d.ts
types/index.d.ts [moved from types/index.esm.d.ts with 100% similarity]
types/tests/animation.ts
types/tests/autogen.js
types/tests/chart_types.ts
types/tests/controllers/bubble_chart_options.ts
types/tests/controllers/doughnut_meta_total.ts
types/tests/controllers/doughnut_offset.ts
types/tests/controllers/doughnut_outer_radius.ts
types/tests/controllers/line_scriptable_parsed_data.ts
types/tests/controllers/line_segments.ts
types/tests/controllers/line_span_gaps.ts
types/tests/controllers/line_styling_array.ts
types/tests/controllers/radar_dataset_indexable_options.ts
types/tests/data_types.ts
types/tests/dataset_null_data.ts
types/tests/defaults.ts
types/tests/elements/scriptable_element_options.ts
types/tests/extensions/plugin.ts
types/tests/extensions/scale.ts
types/tests/interaction.ts
types/tests/layout/position.ts
types/tests/options.ts
types/tests/overrides.ts
types/tests/parsed.data.type.ts
types/tests/plugins/defaults.ts
types/tests/plugins/plugin.decimation/decimation_algorithm.ts
types/tests/plugins/plugin.filler/fill_target_true.ts
types/tests/plugins/plugin.tooltip/chart.tooltip.ts
types/tests/plugins/plugin.tooltip/tooltip_dataset_type.ts
types/tests/plugins/plugin.tooltip/tooltip_parsed_data.ts
types/tests/plugins/plugin.tooltip/tooltip_parsed_data_chart_defaults.ts
types/tests/plugins/plugin.tooltip/tooltip_scriptable_background_color.ts
types/tests/register.ts
types/tests/scales/chart_options.ts
types/tests/scales/options.ts
types/tests/scales/time_string_max.ts
types/tests/scriptable.ts
types/tests/scriptable_core_chart_options.ts
types/tests/test_instance_assignment.ts
types/tests/tsconfig.json

index 5f985010bc6bc54711236e4b69cd4185426b8fda..a261f291755404ef0ada9e519a6bf80c8172d305 100644 (file)
@@ -1 +1 @@
-dist/*.js
+dist/*
index 072c9ab2a5ae3d438ff8de67b9efff3a44ce869b..781df4c2df465d8fd66fcec4b4ecff33cdb1a0c7 100644 (file)
@@ -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"
index 112570e74f43a1db6dd10d0a8d54a94a8e02ad68..a03307d82f598151e58039340df095d2cc78fc68 100644 (file)
@@ -13,6 +13,7 @@ npm-debug.log*
 build/
 # generated typedocs
 docs/api
+docs/.vuepress/dist
 
 # Development
 .DS_Store
similarity index 79%
rename from .size-limit.js
rename to .size-limit.cjs
index 9fbf52b841ef864f50280a37f3ae778d293293b2..e9ea99edd66d8484a4776a0ab2c9b5a7b66bbcbb 100644 (file)
@@ -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 (file)
index 0000000..566f043
--- /dev/null
@@ -0,0 +1,4 @@
+import {Chart} from '../types';
+
+export * from '../types';
+export default Chart;
index 235580fef504a4f6951d661f92b3236b65f39dbe..924a0f900ed84bb840fd6f989cea061f60a38d6b 100644 (file)
@@ -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 (file)
index 95d0a9a..0000000
+++ /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 (file)
index f0bc380..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-import { Chart } from '../types/index.esm';
-
-export * from '../types/index.esm';
-export default Chart;
index 5f89c8f903fc60d8a33a7eb3407214cc09c5e119..b3e1dfbf5d64be356eedcd47177c8b53bf56c746 100644 (file)
@@ -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"
 }
similarity index 98%
rename from docs/.vuepress/config.js
rename to docs/.vuepress/config.cjs
index bff3be11f9553f0b4ff6aac8e96b5ce67e9afdf7..4ada9ffd5f3587707b885a8de9f90c09205ed0c7 100644 (file)
@@ -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 => {
index 79fb100e9e2af74e57270eb6ceab2cc593328473..e74aef8a69c660558a850dbbdf6c9ed6f9c03715 100644 (file)
@@ -5,19 +5,12 @@ Chart.js can be integrated with plain JavaScript or with different module loader
 ## Script Tag
 
 ```html
-<script src="path/to/chartjs/dist/chart.js"></script>
+<script src="path/to/chartjs/dist/chart.umd.js"></script>
 <script>
     const myChart = new Chart(ctx, {...});
 </script>
 ```
 
-## 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, {...});
 });
 ```
index 9334eb2d72f08496a90c7ae974af70a268e508f1..79f7841f3e78430f5ea7ab46567a9dfe2ce0ef11 100644 (file)
@@ -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';
index 39d60b68b1fb1d3ef27b79fb5709ad61d6e0b7e1..dc989488c92aa322efdbbb1af94eb318395db55e 100644 (file)
@@ -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';
index 675f6443a407978f18433f51980365607a452f87..e9b6a9f893f919fd22ec2c7aa5f1b3ab8c4c0ef4 100644 (file)
@@ -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';
index eab68e5f0060c754acc785a58b04a00c5eaad5a3..9cd3cfcf815ffdecff62f1a2d66e684ea3198694 100644 (file)
@@ -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();
similarity index 100%
rename from helpers/helpers.mts
rename to helpers/helpers.d.ts
index a762f589b4a8ff0e1c9e991e8c898cb231bfbf5e..451fa58f7396f4777c448905884eff155cc84c96 100644 (file)
@@ -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 (file)
index ca4eee5..0000000
+++ /dev/null
@@ -1 +0,0 @@
-export * from '../dist/helpers.esm';
index 668b05e7007d2f2b127f2d6b7c2181879c3d7ece..5e45ceaa654aded402dd48dc14fb1715a4deeb32 100644 (file)
@@ -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"
+}
similarity index 93%
rename from karma.conf.js
rename to karma.conf.cjs
index 96cbc0e7a92e19d5abb8f8b236636589e05cc226..cde1d4faa889725301b44526b8fa4cced1dd180f 100644 (file)
@@ -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: {
index d2af668b5a26a3a4b7899bb0bf5aaea6bb108386..601e16e38ee055d5edca30216da36b80017677e8 100644 (file)
@@ -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",
                 "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",
                 "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",
index de4354c49a62e628a10c96249a88172f183355af..23cea7bcab8a0c8e8929155b105a6c7d00c87e45 100644 (file)
@@ -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",
     "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",
similarity index 52%
rename from rollup.config.js
rename to rollup.config.cjs
index aeda6c0cd31d172e54f3184741ebe4d7a6b465c6..d2ca5d36dddd568f7c5043525a3ed99300a2ea49 100644 (file)
@@ -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,
     },
-  },
+  }
 ];
index 19eedbc721c5291f73a1f77f827577c862311536..0859ea04d9df3b59e77d1e4299e3b0703992ca6f 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 /**
- * @typedef { import("../../types/index.esm").ChartOptions } ChartOptions
+ * @typedef { import("../../types").ChartOptions } ChartOptions
  */
 
 /**
index 359240de1cc39c40d2a4a8d0478315e6efe7fb96..a6953ccb539569933b5b488d2adddb8f73cf2cf4 100644 (file)
@@ -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) {
index 5424c862ae19bb89526966d2c0d5634c5cc1974f..776db328804c2c6ffc2639d9bbb57d2bf0efbb4f 100644 (file)
@@ -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
  */
 
 /**
index c1693ca1267ca134f2569d7c7ae5081c350b79be..77aa6fb006e7e9ae5ac7493562b5386141fa06bb 100644 (file)
@@ -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
  */
 
index 98e6705be2fc27d0a64bf32a9e0ba6585c9387da..d79f6fb112fc4dba422b162cafd69eba5596e931 100644 (file)
@@ -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
  */
 
 /**
index ce15bc63108ac43ea0a577b0600d819b88b78e04..1b1d1ff78109ac2dd522361ba76bef4a14c31e38 100644 (file)
@@ -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
  */
index c4f54e0093677b9ec87ddb449afa35aa6dfad3bf..60ffb77d1ea1e57816b40a563fdc86aaac60ae0b 100644 (file)
@@ -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 (file)
index 15865c3..0000000
+++ /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,
-];
index d3539015bf2ae5621a3163e5a3521adc5fb80293..15865c360805b29410a11a7d86f6da820ed53242 100644 (file)
@@ -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 (file)
index 0000000..d353901
--- /dev/null
@@ -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;
index bc22cec888d37dbc3662a3cbcdb46902d49ee72f..70b740d7785c2d3197816ca9943536f7d1fcab3b 100644 (file)
@@ -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) {
index 936111d848f83c1a476f8bad8cc51c074bd47a79..c4d7564a55b726a3218f7c32a26593cd130e4da7 100644 (file)
@@ -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) => {
index bc1689848092b6806f072ec3ee5f8a998d1cc19e..77d40be551625e55455f6c91b7072254619f2994 100644 (file)
@@ -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 = {
index ca267713eb6e5e29867284078e96bb7fb711f04f..900084ffe2a6eceeb3db84df7b9e221a0bdc97d6 100644 (file)
@@ -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 {
index 6754a4f3bbd805215dead71a5295f4f6d1b32079..5be41d8d74bd833c069da3090e24882a15cc4206 100644 (file)
@@ -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"
index 2c5219c7096a6f466102974f6a015ec4e78f9ff7..94f86f2214faf3ea98a1350bcb7595102592e603 100644 (file)
@@ -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)
+  });
 });
similarity index 100%
rename from test/seed-reporter.js
rename to test/seed-reporter.cjs
index bff8bcec7628e4289b11bddc890f4f41881d1d3e..9a2e9d66be332db40860487ac1b97d21bfe17d53 100644 (file)
@@ -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,
index cae40966ba06989764a5481b0ebc9af9b7439af2..7e3e63c8ebede885e67528d135fb515cb20d3122 100644 (file)
@@ -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';
 
index b83204124f86972541c0653536b6e1e7e9f1e9d7..0aece8eae53bf6471f85082a72802df8c02b5b66 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from './index.esm';
+import { Chart } from '.';
 import { AnyObject } from './basic';
 
 export class Animation {
index e6961af9355ff179fb2296bb0620ead615d8b50b..4adb7ee63f2617c21922a07120d161000b4f0f3f 100644 (file)
@@ -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';
index 738643140860418b17f810af52d2abf54fb4b892..a595b6b5b7ecc9be351a43f82ed56c15ee840e7a 100644 (file)
@@ -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(
index b86d6532a518120e61e9740e24bf32c0df5dfa3c..682a5d05abd503dee11fa597f6f51796708c2b4e 100644 (file)
@@ -1,4 +1,4 @@
-import { EasingFunction } from '../index.esm';
+import { EasingFunction } from '..';
 
 export type EasingFunctionSignature = (t: number) => number;
 
index 0bd783fa9703fe4337417ba3b20b1284353e9dd7..b622e71e86a1405622bcdab92432aba8762f985a 100644 (file)
@@ -1,5 +1,5 @@
 import { TRBL, TRBLCorners } from '../geometric';
-import { FontSpec } from '../index.esm';
+import { FontSpec } from '..';
 
 export interface CanvasFontSpec extends FontSpec {
   string: string;
similarity index 100%
rename from types/index.esm.d.ts
rename to types/index.d.ts
index bc9ff433efcbb04179537c52e5b2a083c10ba153..6e38e68eac6be8ce2ef10c3aa8efa87463427cfd 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../index.esm';
+import { Chart } from '..';
 
 const chart = new Chart('id', {
   type: 'bar',
index 6b3770444590dc9d093e047cce3765c2bc941472..584a33636f14ded2c3af72e28182df5e072dc5bc 100644 (file)
@@ -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;
 
index f05bda4da8634ddeb8f4d034f153adcfcb58147c..32831901e2c6534a1932aa1b29a84fc3d6e005c1 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../index.esm';
+import { Chart } from '..';
 
 const chart = new Chart('chart', {
   type: 'bar',
index e036037e6c6c8604934c1930fac217fa5cfd63eb..5924dd5f95620e3d277dec1ee34df30597735171 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart, ChartOptions } from '../../index.esm';
+import { Chart, ChartOptions } from '../..';
 
 const chart = new Chart('test', {
   type: 'bubble',
index da94fa0d8b0f0bf5022cabb159fdcbcb79f9802b..76eb6eb6fb15b93de85e88359db179661bcb888b 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart, ChartMeta, Element } from '../../index.esm';
+import { Chart, ChartMeta, Element } from '../..';
 
 const chart = new Chart('id', {
   type: 'doughnut',
index 58f7546bde2a3eac4ed8daed20d5a0ce90f8a373..cf2d06943869ef647d47924e3ac1c5ca37c17885 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart, ChartMeta, Element } from '../../index.esm';
+import { Chart, ChartMeta, Element } from '../..';
 
 const chart = new Chart('id', {
   type: 'doughnut',
index e1074f39cad69eeb37107cf19f46d148bad9f51e..e72d309c2aa08acff1493662a98427e5026be85a 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../index.esm';
+import { Chart } from '../..';
 
 const chart = new Chart('id', {
   type: 'doughnut',
index da88d0ec2b50a16d1d20c5bddc0ca63b68fc0c02..7a726da37ce3fe4d3966d7b40296c262959508c9 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../index.esm';
+import { Chart } from '../..';
 
 const chart = new Chart('id', {
   type: 'line',
index 9e99e3d21cd0f7392cc903d387131bf84666a203..5d07063a951fc8c22eaaa6055f22baa73bd693fb 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../index.esm';
+import { Chart } from '../..';
 
 const chart = new Chart('id', {
   type: 'line',
index 040c9a99c03a19fbfc667e85e8f02b1948eb3068..0025641bde4138bc7ab96c9f97bc28029a1e148b 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../index.esm';
+import { Chart } from '../..';
 
 const chart = new Chart('id', {
   type: 'line',
index 3b6c6733c451eebeda822b3a51e9ec478a88e6d6..daf2b7be74a472205dddd9dd764642186f67273e 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../index.esm';
+import { Chart } from '../..';
 
 const chart = new Chart('id', {
   type: 'line',
index 0c66f23f6cbc63a542cc28ab86c14bb7f33fad77..7ef753619766a2f5ef37ad7e7645066e2b2ec32e 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart, ChartOptions } from '../../index.esm';
+import { Chart, ChartOptions } from '../..';
 
 const chart = new Chart('test', {
   type: 'radar',
index 1740d8e6690e21c688a9f3fcae591af9b9de1a1f..0e6a2d87f7926dbcc4e1a5a755de8f3dca6705f6 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../index.esm';
+import { Chart } from '..';
 
 const chart = new Chart('chart', {
   type: 'bar',
index ae13c6a2100ceda5a315dcd3dfc6d6d9b9b9ea27..bb86a0aaec317802efd86ce97f7c5e8214498c9a 100644 (file)
@@ -1,4 +1,4 @@
-import { ChartDataset } from '../index.esm';
+import { ChartDataset } from '..';
 
 const dataset: ChartDataset = {
   data: [10, null, 20],
index a3e8e96f5fee836c29602f70a687b19968d8065d..c4c591000ee6c24e50ce962931c3384ee3e213af 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../index.esm';
+import { Chart } from '..';
 
 Chart.defaults.scales.time.time.minUnit = 'day';
 
index c81892d7910beeb5c634cf3ea13b15b00caf9367..791684c64b1e946326ecd6123df50aed6fa0fee2 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../index.esm';
+import { Chart } from '../..';
 
 const chart = new Chart('id', {
   type: 'line',
index fcb0bd0e9b1027efb8936a34bbc9bac758cb3ebf..b0a89c5b08d28b47faaed80e266a4c06a9c7941c 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../index.esm';
+import { Chart } from '../..';
 
 Chart.register({
   id: 'my-plugin',
index fdf1c89e4d5c295dc96a96fedcb841b12eff52a5..0b6a10dcc139355a7d2347fae87fef592c82c5f2 100644 (file)
@@ -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<O extends TestScaleOptions = TestScaleOptions> extends Sc
   }
 }
 
-declare module '../../index.esm' {
+declare module '../..' {
   interface CartesianScaleTypeRegistry {
     test: {
       options: TestScaleOptions
index e5df1da19951801338a7f3a8593a1c8bcd330eb0..3450bbfe0ec86cac4110dbde6b56ab2981542f6b 100644 (file)
@@ -1,6 +1,6 @@
 import {
   Chart, ChartData, ChartConfiguration, Element
-} from '../index.esm';
+} from '..';
 
 const data: ChartData<'line'> = { datasets: [] };
 const chartItem = 'item';
index 87f249e27d3798b7c9174e0b2f831e607c9085ef..544ed4f3ea8cb7f91777bd6364569f074f163365 100644 (file)
@@ -1,4 +1,4 @@
-import { LayoutPosition } from '../../index.esm';
+import { LayoutPosition } from '../..';
 
 const left: LayoutPosition = 'left';
 const right: LayoutPosition = 'right';
index 0aab0f0f7cbc58c20b4db61f0ba20192937fe02d..2ec8b895cfec552a9ab0daf6d35d07354d27087d 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../index.esm';
+import { Chart } from '..';
 
 const chart = new Chart('test', {
   type: 'bar',
index 8c2e02d6cc92e9799b116f858967f19ded19fd99..1e184e561eeaa9ad4691846f1722148d985d7f9c 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../index.esm';
+import { Chart } from '..';
 
 Chart.overrides.bar.scales.x.type = 'time';
 
index c5476eaae395cbfc6996adae1af88b647766ae35..54b207a4bebd344fac5a35db5a607558368f6388 100644 (file)
@@ -1,4 +1,4 @@
-import { ParsedDataType } from '../index.esm';
+import { ParsedDataType } from '..';
 
 interface test {
   pie: ParsedDataType<'pie'>,
index ec54b34ffa14081967bfcb5930d49483273a5f5b..9ca1edea64f1fc02faa2c20539547a7a13278cb8 100644 (file)
@@ -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;
index 978764bde90def9c875153d1c7e6bf1dfb6f1011..a6659bac7c6edd2c8bf86d6a0699bb35a71c738f 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart, DecimationAlgorithm } from '../../../index.esm';
+import { Chart, DecimationAlgorithm } from '../../..';
 
 const chart = new Chart('id', {
   type: 'bubble',
index d9dc21061f0d41b58d7360b9f7940541434bfa0e..3768ddedae895a6f7f74dcc1d8607f47e1a26234 100644 (file)
@@ -1,4 +1,4 @@
-import { ChartDataset } from '../../../index.esm';
+import { ChartDataset } from '../../..';
 
 const dataset: ChartDataset = {
   data: [],
index 66c824412d637cad5f819745882e03744120b66f..56b37f29571371cb33aa4b238ab29bd4c4d04dd6 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../../index.esm';
+import { Chart } from '../../..';
 
 const chart = new Chart('id', {
   type: 'line',
index 989a7cc45f51f9cee9af733598a4002df55bb609..343828d8dd53fafe65a7a2c385beb0211969fa5f 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../../index.esm';
+import { Chart } from '../../..';
 
 const chart = new Chart('id', {
   type: 'line',
index 93b7a9004bacc5d7278a741f0ffc4be027237766..d7fb45959b623d9546d72957a2bf8ce22cde63ca 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../../index.esm';
+import { Chart } from '../../..';
 
 const chart = new Chart('id', {
   type: 'bar',
index 694943e60943f9d98daa24083b3274dc82a6e947..d1488b681cf2a2ddb783016c4fb5c63516437a80 100644 (file)
@@ -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;
index a55d4454781f7d68977bc972d9d93db998352073..36c54d7e0f6167b8428288e0b3d6ee9dcd47630d 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../../index.esm';
+import { Chart } from '../../..';
 
 const chart = new Chart('id', {
   type: 'bar',
index 7256ef8b374c7f2f35cc4cab625e85c041a56a76..49979d7a808b60e792890f79b06ea716d594b4e9 100644 (file)
@@ -24,7 +24,7 @@ import {
   Title,
   SubTitle,
   Tooltip
-} from '../index.esm';
+} from '..';
 
 Chart.register(
   ArcElement,
index a0b02d79af4cb25ff96e7ca0c0cc1cbacb2a4e0b..c097601a9fd9600e0d71b11d0fc55b817e58a077 100644 (file)
@@ -1,4 +1,4 @@
-import { ChartOptions } from '../../index.esm';
+import { ChartOptions } from '../..';
 
 const chartOptions: ChartOptions<'line'> = {
   scales: {
index cc1dc9015d962800f5fababa3200b881e3bb6921..a521f015036e2bf8d490de09559234bd75a9a259 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart, ScaleOptions } from '../../index.esm';
+import { Chart, ScaleOptions } from '../..';
 
 const chart = new Chart('test', {
   type: 'bar',
index 530b1c548e3b32fdd912ad81d89a40fc694ca1c7..9c1c38bf45cafbac11bb39f4d76858ee4071dd81 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../index.esm';
+import { Chart } from '../..';
 
 const chart = new Chart('id', {
   type: 'line',
index db72edb21ff202a6dca1813a2c917fe7307edd85..bf9cec805264bf972d38d2da583181e140b01d38 100644 (file)
@@ -1,4 +1,4 @@
-import { ChartType, Scriptable, ScriptableContext } from '../index.esm';
+import { ChartType, Scriptable, ScriptableContext } from '..';
 
 interface test {
   pie?: Scriptable<number, ScriptableContext<'pie'>>,
index 2c81f592e6cc286c56c4c38a4aaf44fd9a123a24..3e2115f655fe8089a7e92facee1f76aea7b8ce21 100644 (file)
@@ -1,4 +1,4 @@
-import { ChartConfiguration } from '../index.esm';
+import { ChartConfiguration } from '..';
 
 const getConfig = (): ChartConfiguration<'bar'> => {
   return {
index 044f53f7cfbf7cc7b7605036a34ddb9db0d64ed9..ea3951d2ead0f88ff214d0a1d3012a0bd8e87122 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../index.esm';
+import { Chart } from '..';
 
 const chart = new Chart('id', {
   type: 'scatter',
index 9bbed3c55d642f591880b6c3a2a3c12fbb82a27e..a8494a0a8ae37e2eb22a03e96515a7e337099d45 100644 (file)
@@ -8,6 +8,6 @@
   },
   "include": [
     "./**/*.ts",
-    "../index.esm.d.ts"
+    "../index.d.ts"
   ]
 }