scalableminds / amd-optimize

An AMD (RequireJS) optimizer that's stream-friendly. Made for gulp.
MIT License
163 stars 29 forks source link

wrapFile, include #8

Open normanrz opened 10 years ago

normanrz commented 10 years ago

Append/prepend other files or modules to bundle

Log Time

tamtakoe commented 9 years ago

options.include doesn't work now?

normanrz commented 9 years ago

No, options.include is not supported yet. I'll happily accept PRs on that :-)

tamtakoe commented 9 years ago

It is not necessarily.

You can write in docs temporary descision:

.pipe(amdOptimize('main', {}))
.pipe(require('gulp-add-src')('other_amd_file.js'));
normanrz commented 9 years ago

Yeah, you're right. Turns out there is already a recipe in the readme for that using the event-stream module: https://github.com/scalableminds/amd-optimize#recommended-modules

engyii commented 9 years ago

it's A solution but not THE solution :) I've used it for a bunch of simple modules containing viewmodels but I can't include the matching templates files... they can't go through amdoptimize and the require plugins (!text for now...) this way.

jods4 commented 9 years ago

:+1: for include. It's a really great tool when you want to include dynamic dependencies inside a bundle.

I would suggest a PR but I'm not at ease with coffeescript. I don't think this should be a very difficult feature, as it's just a matter of looping over the include and applying the same logic as you apply to the main module.

Currently I work around this by using merge-stream and gulp-unique-files. I loop over my include array and call amd-optimize for each entry, then I merge all the resulting streams and remove dups with gulp-unique-files. Could be a recipe in the readme until include is supported.

Another work-around I found is to build a fake file dynamically that requires everything you want to include and amd-optimize this.