Skip to content

Commit 52f8ccc

Browse files
committed
No anonymous modules in standalone build. Fixes selectize#89.
1 parent d3a4aca commit 52f8ccc

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

Gruntfile.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,26 @@ module.exports = function(grunt) {
184184
},
185185
files: {
186186
'dist/js/standalone/selectize.js': (function() {
187-
var files = [];
188-
for (var i = 0, n = files_js_dependencies.length; i < n; i++) {
189-
files.push(files_js_dependencies[i]);
187+
var files, i, n, source, name, path;
188+
189+
// amd definitions must be changed to be not anonymous
190+
// @see https://github.com/brianreavis/selectize.js/issues/89
191+
path = 'dist/js/selectize.js';
192+
source = fs.readFileSync(path, 'utf8').replace(/define\((.*?)factory\);/, 'define(\'selectize\', $1factory);');
193+
fs.writeFileSync('selectize.tmp.js', source, 'utf8');
194+
195+
// dependencies
196+
files = [];
197+
for (i = 0, n = files_js_dependencies.length; i < n; i++) {
198+
path = files_js_dependencies[i];
199+
name = path.match(/([^\/]+?).js$/)[1];
200+
source = fs.readFileSync(path, 'utf8').replace('define(factory);', 'define(\'' + name + '\', factory);');
201+
fs.writeFileSync(path, source, 'utf8');
202+
203+
files.push(path);
190204
}
191-
files.push('dist/js/selectize.js');
205+
206+
files.push('selectize.tmp.js');
192207
return files;
193208
})()
194209
}

0 commit comments

Comments
 (0)