mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 12:19:08 +02:00
3671c01c26
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.
83 lines
1.6 KiB
JavaScript
83 lines
1.6 KiB
JavaScript
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 inputESM = {
|
|
'dist/chart.esm': 'src/index.esm.js',
|
|
'dist/helpers.esm': 'src/helpers/index.js'
|
|
};
|
|
|
|
const banner = `/*!
|
|
* Chart.js v${pkg.version}
|
|
* ${pkg.homepage}
|
|
* (c) ${(new Date(process.env.SOURCE_DATE_EPOCH ? (process.env.SOURCE_DATE_EPOCH * 1000) : new Date().getTime())).getFullYear()} Chart.js Contributors
|
|
* Released under the MIT License
|
|
*/`;
|
|
|
|
module.exports = [
|
|
// UMD builds
|
|
// dist/chart.min.js
|
|
// dist/chart.js
|
|
{
|
|
input,
|
|
plugins: [
|
|
json(),
|
|
resolve(),
|
|
cleanup({
|
|
sourcemap: true
|
|
}),
|
|
analyze({summaryOnly: true})
|
|
],
|
|
output: {
|
|
name: 'Chart',
|
|
file: 'dist/chart.js',
|
|
banner,
|
|
format: 'umd',
|
|
indent: false,
|
|
},
|
|
},
|
|
{
|
|
input,
|
|
plugins: [
|
|
json(),
|
|
resolve(),
|
|
terser({
|
|
output: {
|
|
preamble: banner
|
|
}
|
|
}),
|
|
],
|
|
output: {
|
|
name: 'Chart',
|
|
file: 'dist/chart.min.js',
|
|
format: 'umd',
|
|
indent: false,
|
|
},
|
|
},
|
|
|
|
// ES6 builds
|
|
// dist/chart.esm.js
|
|
// helpers/*.js
|
|
{
|
|
input: inputESM,
|
|
plugins: [
|
|
json(),
|
|
resolve(),
|
|
cleanup({
|
|
sourcemap: true
|
|
}),
|
|
],
|
|
output: {
|
|
dir: './',
|
|
chunkFileNames: 'dist/chunks/[name].js',
|
|
banner,
|
|
format: 'esm',
|
|
indent: false,
|
|
},
|
|
},
|
|
];
|