]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
ESM build, with helpers separated (#7400)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Tue, 23 Jun 2020 23:02:51 +0000 (02:02 +0300)
committerGitHub <noreply@github.com>
Tue, 23 Jun 2020 23:02:51 +0000 (19:02 -0400)
* ESM build, with helpers separated
* Remove umd environment
* Include the chunks in package

.gitignore
karma.conf.js
package.json
rollup.config.js
src/index.esm.js [new file with mode: 0644]

index 3adb827bd0c73bcdefc58aa524cf544af5ee6811..e941ca2d84cdcdab53ff60ad2acaaab9c0c02dee 100644 (file)
@@ -3,6 +3,7 @@
 /custom
 /dist
 /gh-pages
+/helpers
 
 # Node.js
 node_modules/
index 9ca016bd973e5b0fa8f2f9e5c1e6c080309b6f78..8ae923eb47aae49a665f4bbf2d935213f2773592 100644 (file)
@@ -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'],
index 288116294a66db8fc871cb6d2cf1566a3970ae87..546328c0832388009900aa5fdb50db783f870a9d 100644 (file)
@@ -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",
index 51a4bc5e5ee59eeb7a0a6c84e6ede6e885e631e2..785a335b86b5bc6243b664682e52c465c770080b 100644 (file)
@@ -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,
-               },
-       },
+       }
 ];
diff --git a/src/index.esm.js b/src/index.esm.js
new file mode 100644 (file)
index 0000000..3222ea4
--- /dev/null
@@ -0,0 +1,6 @@
+export * from './controllers';
+export * from './core';
+export * from './elements';
+export * from './platform';
+export * from './plugins';
+export * from './scales';