]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Adds support for ES6 modules (#6619)
authorSebastian Niemann <SebastianNiemann@users.noreply.github.com>
Sun, 27 Oct 2019 22:28:25 +0000 (23:28 +0100)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sun, 27 Oct 2019 22:28:25 +0000 (18:28 -0400)
package.json
rollup.config.js

index bc96c7af8f8f07794f2f688966433beaf6dfcb32..2fcc795b5d26766c55eb153d01976d4ce8d4d48f 100644 (file)
@@ -7,6 +7,7 @@
   "jsdelivr": "dist/Chart.min.js",
   "unpkg": "dist/Chart.min.js",
   "main": "dist/Chart.js",
+  "module": "dist/Chart.esm.js",
   "keywords": [
     "canvas",
     "charts",
index 08f0d8efc67f1e910ac78ed1ddab359a859886b3..b7c23e0c6e8964b991d81c4388354c1d31341c17 100644 (file)
@@ -17,6 +17,66 @@ const banner = `/*!
  */`;
 
 module.exports = [
+       // ES6 builds (excluding moment)
+       // dist/Chart.esm.min.js
+       // dist/Chart.esm.js
+       {
+               input: input,
+               plugins: [
+                       resolve(),
+                       commonjs(),
+                       babel({
+                               exclude: 'node_modules/**'
+                       }),
+                       stylesheet({
+                               extract: true
+                       }),
+               ],
+               output: {
+                       name: 'Chart',
+                       file: 'dist/Chart.esm.js',
+                       banner: banner,
+                       format: 'esm',
+                       indent: false,
+                       globals: {
+                               moment: 'moment'
+                       }
+               },
+               external: [
+                       'moment'
+               ]
+       },
+       {
+               input: input,
+               plugins: [
+                       resolve(),
+                       commonjs(),
+                       babel({
+                               exclude: 'node_modules/**'
+                       }),
+                       stylesheet({
+                               extract: true,
+                               minify: true
+                       }),
+                       terser({
+                               output: {
+                                       preamble: banner
+                               }
+                       })
+               ],
+               output: {
+                       name: 'Chart',
+                       file: 'dist/Chart.esm.min.js',
+                       format: 'esm',
+                       indent: false,
+                       globals: {
+                               moment: 'moment'
+                       }
+               },
+               external: [
+                       'moment'
+               ]
+       },
        // UMD builds (excluding moment)
        // dist/Chart.min.js
        // dist/Chart.js
@@ -84,6 +144,51 @@ module.exports = [
                ]
        },
 
+       // ES6 builds (including moment)
+       // dist/Chart.bundle.esm.min.js
+       // dist/Chart.bundle.esm.js
+       {
+               input: input,
+               plugins: [
+                       resolve(),
+                       commonjs(),
+                       babel({
+                               exclude: 'node_modules/**'
+                       }),
+                       stylesheet()
+               ],
+               output: {
+                       name: 'Chart',
+                       file: 'dist/Chart.bundle.esm.js',
+                       banner: banner,
+                       format: 'esm',
+                       indent: false
+               }
+       },
+       {
+               input: input,
+               plugins: [
+                       resolve(),
+                       commonjs(),
+                       babel({
+                               exclude: 'node_modules/**'
+                       }),
+                       stylesheet({
+                               minify: true
+                       }),
+                       terser({
+                               output: {
+                                       preamble: banner
+                               }
+                       })
+               ],
+               output: {
+                       name: 'Chart',
+                       file: 'dist/Chart.bundle.esm.min.js',
+                       format: 'esm',
+                       indent: false
+               }
+       },
        // UMD builds (including moment)
        // dist/Chart.bundle.min.js
        // dist/Chart.bundle.js