Skip to content

Commit

Permalink
No anonymous modules in standalone build. Fixes selectize#89.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianreavis committed Nov 25, 2013
1 parent d3a4aca commit 52f8ccc
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,26 @@ module.exports = function(grunt) {
},
files: {
'dist/js/standalone/selectize.js': (function() {
var files = [];
for (var i = 0, n = files_js_dependencies.length; i < n; i++) {
files.push(files_js_dependencies[i]);
var files, i, n, source, name, path;

// amd definitions must be changed to be not anonymous
// @see https://github.com/brianreavis/selectize.js/issues/89
path = 'dist/js/selectize.js';
source = fs.readFileSync(path, 'utf8').replace(/define\((.*?)factory\);/, 'define(\'selectize\', $1factory);');
fs.writeFileSync('selectize.tmp.js', source, 'utf8');

// dependencies
files = [];
for (i = 0, n = files_js_dependencies.length; i < n; i++) {
path = files_js_dependencies[i];
name = path.match(/([^\/]+?).js$/)[1];
source = fs.readFileSync(path, 'utf8').replace('define(factory);', 'define(\'' + name + '\', factory);');
fs.writeFileSync(path, source, 'utf8');

files.push(path);
}
files.push('dist/js/selectize.js');

files.push('selectize.tmp.js');
return files;
})()
}
Expand Down

0 comments on commit 52f8ccc

Please sign in to comment.