Add no-es5-compat option during build. Add option to include/exclude stateful module during build.

This commit is contained in:
kangax 2013-05-14 12:34:45 -04:00
parent b2bcb3aff5
commit 6f306a6436
5 changed files with 17 additions and 2 deletions

View file

@ -110,6 +110,7 @@ Additional flags for build script are:
- **no-strict** — Strips "use strict" directives from source
- **no-svg-export** — Removes svg exporting functionality
- **no-es5-compat** - Removes ES5 compat methods (Array.prototype.*, String.prototype.*, Function.prototype.*)
For example:

View file

@ -30,6 +30,7 @@ else if (minifier === 'uglifyjs') {
var includeAllModules = modulesToInclude.length === 1 && modulesToInclude[0] === 'ALL';
var noStrict = 'no-strict' in buildArgsAsObject;
var noSVGExport = 'no-svg-export' in buildArgsAsObject;
var noES5Compat = 'no-es5-compat' in buildArgsAsObject;
var distFileContents =
'/* build: `node build.js modules=' +
@ -37,6 +38,7 @@ var distFileContents =
(modulesToExclude.length ? (' exclude=' + modulesToExclude.join(',')) : '') +
(noStrict ? ' no-strict' : '') +
(noSVGExport ? ' no-svg-export' : '') +
(noES5Compat ? ' no-es5-compat' : '') +
'` */\n';
function appendFileContents(fileNames, callback) {
@ -62,6 +64,9 @@ function appendFileContents(fileNames, callback) {
if (noSVGExport) {
strData = strData.replace(/\/\* _TO_SVG_START_ \*\/[\s\S]*\/\* _TO_SVG_END_ \*\//, '');
}
if (noES5Compat) {
strData = strData.replace(/\/\* _ES5_COMPAT_START_ \*\/[\s\S]*\/\* _ES5_COMPAT_END_ \*\//, '');
}
distFileContents += (strData + '\n');
readNextFile();
});
@ -142,7 +147,8 @@ var filesToInclude = [
'src/object.class.js',
'src/object_origin.mixin.js',
'src/object_geometry.mixin.js',
'src/stateful.mixin.js',
ifSpecifiedInclude('stateful', 'src/stateful.mixin.js'),
ifSpecifiedInclude('interaction', 'src/object_interactivity.mixin.js'),

View file

@ -2,6 +2,8 @@
var slice = Array.prototype.slice;
/* _ES5_COMPAT_START_ */
if (!Array.prototype.indexOf) {
/**
* Finds index of an element in an array
@ -166,6 +168,8 @@
};
}
/* _ES5_COMPAT_END_ */
/**
* Invokes method on all items in a given array
* @memberOf fabric.util.array

View file

@ -1,3 +1,4 @@
/* _ES5_COMPAT_START_ */
(function() {
var slice = Array.prototype.slice,
@ -32,4 +33,5 @@
};
}
})();
})();
/* _ES5_COMPAT_END_ */

View file

@ -1,5 +1,6 @@
(function() {
/* _ES5_COMPAT_START_ */
if (!String.prototype.trim) {
/**
* Trims a string (removing whitespace from the beginning and the end)
@ -11,6 +12,7 @@ if (!String.prototype.trim) {
return this.replace(/^[\s\xA0]+/, '').replace(/[\s\xA0]+$/, '');
};
}
/* _ES5_COMPAT_END_ */
/**
* Camelizes a string