mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
ESM build, with helpers separated (#7400)
* ESM build, with helpers separated * Remove umd environment * Include the chunks in package
This commit is contained in:
parent
8ac700961a
commit
40e9029a59
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@
|
||||
/custom
|
||||
/dist
|
||||
/gh-pages
|
||||
/helpers
|
||||
|
||||
# Node.js
|
||||
node_modules/
|
||||
|
||||
@ -21,7 +21,7 @@ module.exports = function(karma) {
|
||||
// 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 build = builds.filter(v => v.output.file.match(regex))[0];
|
||||
const build = builds.filter(v => v.output.file && v.output.file.match(regex))[0];
|
||||
|
||||
karma.set({
|
||||
frameworks: ['jasmine'],
|
||||
|
||||
@ -24,9 +24,8 @@
|
||||
"url": "https://github.com/chartjs/Chart.js/issues"
|
||||
},
|
||||
"files": [
|
||||
"composer.json",
|
||||
"dist/*.css",
|
||||
"dist/*.js"
|
||||
"dist/*.js",
|
||||
"helpers/**/*.js"
|
||||
],
|
||||
"scripts": {
|
||||
"autobuild": "rollup -c -w",
|
||||
@ -57,6 +56,7 @@
|
||||
"eslint-config-chartjs": "^0.2.0",
|
||||
"eslint-config-esnext": "^4.1.0",
|
||||
"eslint-plugin-html": "^6.0.2",
|
||||
"glob": "^7.1.6",
|
||||
"jasmine": "^3.5.0",
|
||||
"jasmine-core": "^3.5.0",
|
||||
"karma": "^5.0.9",
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
|
||||
const babel = require('rollup-plugin-babel');
|
||||
const cleanup = require('rollup-plugin-cleanup');
|
||||
const glob = require('glob');
|
||||
const inject = require('@rollup/plugin-inject');
|
||||
const json = require('@rollup/plugin-json');
|
||||
const resolve = require('@rollup/plugin-node-resolve').default;
|
||||
@ -10,6 +11,14 @@ 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',
|
||||
};
|
||||
glob('src/helpers/helpers.*.js', (_er, files) => {
|
||||
files.forEach(file => {
|
||||
inputESM[file.replace(/src\/|helpers\.|\.js/g, '')] = file;
|
||||
});
|
||||
});
|
||||
|
||||
const banner = `/*!
|
||||
* Chart.js v${pkg.version}
|
||||
@ -67,10 +76,10 @@ module.exports = [
|
||||
},
|
||||
|
||||
// ES6 builds
|
||||
// dist/chart.esm.min.js
|
||||
// dist/chart.esm.js
|
||||
// helpers/*.js
|
||||
{
|
||||
input,
|
||||
input: inputESM,
|
||||
plugins: [
|
||||
json(),
|
||||
resolve(),
|
||||
@ -79,29 +88,11 @@ module.exports = [
|
||||
})
|
||||
],
|
||||
output: {
|
||||
name: 'Chart',
|
||||
file: 'dist/chart.esm.js',
|
||||
dir: './',
|
||||
chunkFileNames: 'helpers/chunks/[name].js',
|
||||
banner,
|
||||
format: 'esm',
|
||||
indent: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
input,
|
||||
plugins: [
|
||||
json(),
|
||||
resolve(),
|
||||
terser({
|
||||
output: {
|
||||
preamble: banner
|
||||
}
|
||||
})
|
||||
],
|
||||
output: {
|
||||
name: 'Chart',
|
||||
file: 'dist/chart.esm.min.js',
|
||||
format: 'esm',
|
||||
indent: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
6
src/index.esm.js
Normal file
6
src/index.esm.js
Normal file
@ -0,0 +1,6 @@
|
||||
export * from './controllers';
|
||||
export * from './core';
|
||||
export * from './elements';
|
||||
export * from './platform';
|
||||
export * from './plugins';
|
||||
export * from './scales';
|
||||
Loading…
x
Reference in New Issue
Block a user