Content-Length: 522164 | pFad | https://github.com/chartjs/chartjs-plugin-deferred/commit/d22f5a0a6b8556b9ebee3ca966137bbea749bab7

ED Use rollup to build UMD dist files (#2) · chartjs/chartjs-plugin-deferred@d22f5a0 · GitHub
Skip to content

Commit d22f5a0

Browse files
committed
Use rollup to build UMD dist files (#2)
1 parent 5b2cd63 commit d22f5a0

File tree

5 files changed

+41
-23
lines changed

5 files changed

+41
-23
lines changed

.eslintrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ ecmaFeatures:
22
modules: true
33
jsx: true
44

5+
parserOptions:
6+
sourceType: module
7+
58
env:
6-
amd: true
79
browser: true
810
es6: true
9-
jquery: true
1011
node: true
1112

1213
# http://eslint.org/docs/rules/

gulpfile.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
var argv = require('yargs').argv;
44
var gulp = require('gulp');
55
var eslint = require('gulp-eslint');
6-
var insert = require('gulp-insert');
76
var file = require('gulp-file');
87
var rename = require('gulp-rename');
98
var replace = require('gulp-replace');
@@ -13,22 +12,14 @@ var gutil = require('gulp-util');
1312
var zip = require('gulp-zip');
1413
var merge = require('merge2');
1514
var path = require('path');
15+
var rollup = require('rollup-stream');
16+
var source = require('vinyl-source-stream');
1617
var pkg = require('./package.json');
1718

1819
var srcDir = './src/';
1920
var outDir = './dist/';
2021
var samplesDir = './samples/';
2122

22-
var header = `/*!
23-
* ` + pkg.name + `
24-
* http://chartjs.org/
25-
* Version: {{ version }}
26-
*
27-
* Copyright 2017 Simon Brunel
28-
* Released under the MIT license
29-
* https://github.com/chartjs/chartjs-plugin-deferred/blob/master/LICENSE.md
30-
*/`;
31-
3223
function watch(glob, task) {
3324
gutil.log('Waiting for changes...');
3425
return gulp.watch(glob, function(e) {
@@ -43,10 +34,8 @@ gulp.task('default', ['build']);
4334

4435
gulp.task('build', function() {
4536
var task = function() {
46-
return gulp.src(srcDir + 'plugin.js')
47-
.pipe(rename(pkg.name + '.js'))
48-
.pipe(insert.prepend(header))
49-
.pipe(streamify(replace('{{ version }}', pkg.version)))
37+
return rollup('rollup.config.js')
38+
.pipe(source(pkg.name + '.js'))
5039
.pipe(gulp.dest(outDir))
5140
.pipe(rename(pkg.name + '.min.js'))
5241
.pipe(streamify(uglify({preserveComments: 'license'})))

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,29 @@
44
"description": "Chart.js plugin to defer initial chart updates",
55
"version": "0.2.0",
66
"license": "MIT",
7-
"main": "src/plugin.js",
7+
"main": "dist/chartjs-plugin-deferred.js",
88
"repository": {
99
"type": "git",
1010
"url": "https://github.com/chartjs/chartjs-plugin-deferred.git"
1111
},
1212
"devDependencies": {
1313
"gulp": "^3.9.1",
1414
"gulp-eslint": "^3.0.0",
15-
"gulp-insert": "^0.5.0",
1615
"gulp-file": "^0.3.0",
17-
"gulp-replace": "^0.5.4",
1816
"gulp-rename": "^1.2.2",
17+
"gulp-replace": "^0.5.4",
1918
"gulp-streamify": "^1.0.2",
2019
"gulp-uglify": "^1.5.3",
2120
"gulp-util": "^3.0.7",
2221
"gulp-zip": "^3.2.0",
2322
"merge2": "^1.0.2",
2423
"path": "^0.12.7",
24+
"rollup": "^0.41.6",
25+
"rollup-stream": "^1.19.0",
26+
"vinyl-source-stream": "^1.1.0",
2527
"yargs": "^4.7.1"
28+
},
29+
"peerDependencies": {
30+
"chart.js": ">= 2.5.0 < 3"
2631
}
2732
}

rollup.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const pkg = require('./package.json');
2+
3+
const banner = `/*!
4+
* ` + pkg.name + `
5+
* http://chartjs.org/
6+
* Version: `+ pkg.version + `
7+
*
8+
* Copyright ` + (new Date().getFullYear()) + ` Simon Brunel
9+
* Released under the MIT license
10+
* https://github.com/chartjs/` + pkg.name + `/blob/master/LICENSE.md
11+
*/`;
12+
13+
export default {
14+
entry: 'src/plugin.js',
15+
dest: 'dist/' + pkg.name + '.js',
16+
banner: banner,
17+
format: 'umd',
18+
external: [
19+
'chart.js'
20+
],
21+
globals: {
22+
'chart.js': 'Chart'
23+
}
24+
};

src/plugin.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
/* global window: false */
21
'use strict';
32

4-
(function() {
3+
import Chart from 'chart.js';
54

6-
var Chart = window.Chart;
5+
(function() {
76
var helpers = Chart.helpers;
87
var STUB_KEY = '_chartjs_deferred';
98
var MODEL_KEY = '_deferred_model';

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/chartjs/chartjs-plugin-deferred/commit/d22f5a0a6b8556b9ebee3ca966137bbea749bab7

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy