Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UMD support #3

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var rename = require('gulp-rename');
var replace = require('gulp-replace');
var streamify = require('gulp-streamify');
var uglify = require('gulp-uglify');
var umd = require('gulp-umd');
var gutil = require('gulp-util');
var zip = require('gulp-zip');
var merge = require('merge2');
Expand Down Expand Up @@ -46,6 +47,17 @@ function watch(glob, task) {
function buildTask() {
var task = function() {
return gulp.src(srcDir + 'plugin.js')
.pipe(umd({
dependencies: function(file) {
return [{
name: 'chart.js',
amd: 'chart.js',
cjs: 'chart.js',
global: 'Chart',
param: 'Chart'
}];
}
}))
.pipe(rename(package.name + '.js'))
.pipe(insert.prepend(header))
.pipe(streamify(replace('{{ version }}', package.version)))
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
"devDependencies": {
"gulp": "^3.9.1",
"gulp-eslint": "^3.0.0",
"gulp-insert": "^0.5.0",
"gulp-file": "^0.3.0",
"gulp-replace": "^0.5.4",
"gulp-insert": "^0.5.0",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.4",
"gulp-streamify": "^1.0.2",
"gulp-uglify": "^1.5.3",
"gulp-umd": "^0.2.1",
"gulp-util": "^3.0.7",
"gulp-zip": "^3.2.0",
"merge2": "^1.0.2",
Expand Down
9 changes: 3 additions & 6 deletions src/plugin.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/* global window: false */
/* global window: false, Chart */
'use strict';

(function() {

var Chart = window.Chart;
(function(Chart) {
var helpers = Chart.helpers;
var STUB_KEY = '_chartjs_deferred';
var MODEL_KEY = '_deferred_model';
Expand Down Expand Up @@ -202,5 +200,4 @@
}
}
});

}());
}(Chart || window.Chart));