]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Distribute types as is (#8720)
authorJosh Kelley <joshkel@gmail.com>
Thu, 25 Mar 2021 19:08:00 +0000 (15:08 -0400)
committerGitHub <noreply@github.com>
Thu, 25 Mar 2021 19:08:00 +0000 (15:08 -0400)
I had initially seen some oddities around type augmentation for type definitions in subdirectories of `types`, and using Rollup seemed to help with that. However, now that all of Chart.js's main types are directly under `types`, there seems to be no need for this.

This simplifies the build process, since it no longer needs to use rollup-plugin-dts.

It also improves some third-party tools. For example, I'm in the habit of using WebStorm's "Go To Declaration or Usages" hotkey with third-party TypeScript definitions as a quick way of getting more information about an API. With the Rollup-generate types, that works poorly; WebStorm goes to the imported-and-re-exported symbol within the barely-readable machine-generated dist/chart.esm.d.ts file, and I have to navigate two more hops to find the actual definitions.

MAINTAINING.md
package-lock.json
package.json
rollup.config.js
types/index.esm.d.ts

index 53917a504c0a34ac11bd1f7c87def398091c9212..50976a19a35ab8451314174f4dc2cfb0f16729dd 100644 (file)
@@ -13,7 +13,7 @@ Chart.js relies on [Travis CI](https://travis-ci.org/) to automate the library [
 Creation of this tag triggers a new build:
 
 * `Chart.js.zip` package is generated, containing dist files and examples
-* `dist/*.js` and `Chart.js.zip` are attached to the GitHub release (downloads)
+* `dist/*.js`, `types/*.ts`, and `Chart.js.zip` are attached to the GitHub release (downloads)
 * A new npm package is published on [npmjs](https://www.npmjs.com/package/chart.js)
 
 Finally, [cdnjs](https://cdnjs.com/libraries/Chart.js) is automatically updated from the npm release.
index 5c1d6212d637bbe964d44f633af47c0dd72cfe94..9d90b0709a63c843a93bbf1b83cb4ac6882cff0d 100644 (file)
         "rollup-pluginutils": "^2.8.2"
       }
     },
-    "rollup-plugin-dts": {
-      "version": "3.0.1",
-      "resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-3.0.1.tgz",
-      "integrity": "sha512-sdTsd0tEIV1b5Bio1k4Ei3N4/7jbwcVRdlYotGYdJOKR59JH7DzqKTSCbfaKPzuAcKTp7k317z2BzYJ3bkhDTw==",
-      "dev": true,
-      "requires": {
-        "@babel/code-frame": "^7.12.13",
-        "magic-string": "^0.25.7"
-      },
-      "dependencies": {
-        "@babel/code-frame": {
-          "version": "7.12.13",
-          "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.13.tgz",
-          "integrity": "sha512-HV1Cm0Q3ZrpCR93tkWOYiuYIgLxZXZFVG2VgK+MBWjUqZTundupbfx2aXarXuw5Ko5aMcjtJgbSs4vUGBS5v6g==",
-          "dev": true,
-          "optional": true,
-          "requires": {
-            "@babel/highlight": "^7.12.13"
-          }
-        },
-        "@babel/highlight": {
-          "version": "7.13.10",
-          "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.13.10.tgz",
-          "integrity": "sha512-5aPpe5XQPzflQrFwL1/QoeHkP2MsA4JCntcXHRhEsdsfPVkvPi2w7Qix4iV7t5S/oC9OodGrggd8aco1g3SZFg==",
-          "dev": true,
-          "optional": true,
-          "requires": {
-            "@babel/helper-validator-identifier": "^7.12.11",
-            "chalk": "^2.0.0",
-            "js-tokens": "^4.0.0"
-          }
-        }
-      }
-    },
     "rollup-plugin-istanbul": {
       "version": "3.0.0",
       "resolved": "https://registry.npmjs.org/rollup-plugin-istanbul/-/rollup-plugin-istanbul-3.0.0.tgz",
index 9741b28ec4df64f2202679b46c103a8d66eb66b5..8b16bb988d36baace5b4919da2b7036a1fdb5409 100644 (file)
@@ -8,7 +8,7 @@
   "unpkg": "dist/chart.min.js",
   "main": "dist/chart.js",
   "module": "dist/chart.esm.js",
-  "types": "dist/chart.esm.d.ts",
+  "types": "types/chart.esm.d.ts",
   "keywords": [
     "canvas",
     "charts",
@@ -28,9 +28,9 @@
     "auto/**/*.js",
     "auto/**/*.d.ts",
     "dist/*.js",
-    "dist/*.d.ts",
     "dist/chunks/*.js",
-    "dist/chunks/*.d.ts",
+    "types/*.d.ts",
+    "types/helpers/*.d.ts",
     "helpers/**/*.js",
     "helpers/**/*.d.ts"
   ],
@@ -84,7 +84,6 @@
     "rollup": "^2.41.4",
     "rollup-plugin-analyzer": "^4.0.0",
     "rollup-plugin-cleanup": "^3.2.1",
-    "rollup-plugin-dts": "^3.0.1",
     "rollup-plugin-istanbul": "^3.0.0",
     "rollup-plugin-terser": "^7.0.2",
     "typedoc": "^0.20.32",
index ded52caff1796d3cec2df5cf9e17c287d44a9f1b..6f05bff34a7bcc74850e9e0393b03b554cc57ad3 100644 (file)
@@ -1,6 +1,5 @@
 const analyze = require('rollup-plugin-analyzer');
 const cleanup = require('rollup-plugin-cleanup');
-const dts = require('rollup-plugin-dts').default;
 const json = require('@rollup/plugin-json');
 const resolve = require('@rollup/plugin-node-resolve').default;
 const terser = require('rollup-plugin-terser').terser;
@@ -11,10 +10,6 @@ const inputESM = {
   'dist/chart.esm': 'src/index.esm.js',
   'dist/helpers.esm': 'src/helpers/index.js'
 };
-const inputESMTypings = {
-  'dist/chart.esm': 'types/index.esm.d.ts',
-  'dist/helpers.esm': 'types/helpers/index.d.ts'
-};
 
 const banner = `/*!
  * Chart.js v${pkg.version}
@@ -84,20 +79,4 @@ module.exports = [
       indent: false,
     },
   },
-  // ES6 Typings builds
-  // dist/chart.esm.d.ts
-  // helpers/*.d.ts
-  {
-    input: inputESMTypings,
-    plugins: [
-      dts()
-    ],
-    output: {
-      dir: './',
-      chunkFileNames: 'dist/chunks/[name].ts',
-      banner,
-      format: 'esm',
-      indent: false,
-    },
-  }
 ];
index 3fb3ea3b7eb069bb2ed88b78dbc3066f27c75bfe..f8e8609f8d854731c3d4a7e762af393834ad71fe 100644 (file)
@@ -1,17 +1,3 @@
-/**
- * Top-level type definitions. These are processed by Rollup and rollup-plugin-dts
- * to make a combined .d.ts file under dist; that way, all of the type definitions
- * appear directly within the "chart.js" module; that matches the layout of the
- * distributed chart.esm.js bundle and means that users of Chart.js can easily use
- * module augmentation to extend Chart.js's types and plugins within their own
- * code, like so:
- *
- * @example
- * declare module "chart.js" {
- *   // Add types here
- * }
- */
-
 import { DeepPartial, DistributiveArray, UnionToIntersection } from './utils';
 
 import { TimeUnit } from './adapters';