Closed berekuk closed 11 years ago
Thanks for recording the issue!!
I'll preface this by saying that guessing which files are root files to optimize is an inexact science.
That said, what mimosa presumes is that anything containing an outer level require/requirejs call -- unless it is the common setup file (which you don't have) -- is a file to be optimized. A require
inside a define
callback won't cause any issues, but a require sitting alone on the outside will. You could eliminate the app.js
from being optimized by switching your require
call to a define
. I obviously can't run your app to see what effect that will have, but I don't think it should have any.
The require('underscore')
in the backbone file is probably causing the trouble. That is something I need to brainstorm on. That said, James Burke, the guy behind RequireJS, keeps AMD shimmed versions of Backbone and Underscore available to use if you rather not shim. If you were to switch over to them, you wouldn't need to shim, and the vendor problem would go away.
One other thing I noticed...a ton ton ton of JSHint and CSSLint errors. If you renamed vendors
to vendor
many of these would go away. By default Mimosa won't lint/hint vendor code and vendor
is where it expects to find that code.
I'd love to know how this would turn out in your app...
app.js
from require
to define
I need to think on some fixes for this. Because it is real hard to figure out the actual files 100% perfectly, no matter what mechanism I use, I may just need to include an optimizeThis
array of paths to the files that actually ought to be optimized.
I've also got on my short list of things to do to allow for configuring what you would like your vendor
directory to be named. So if you put your vendor code in scripts
or something like that, all the benefit mimosa gives things in vendor
would be conveyed.
Thank you! Replacing require
with define
fixed everything. Strangely, backbone.js
isn't getting optimized anymore (and mimoza build -o --debug
says "Mimosa found 1 base config files"), even though I didn't replace it with AMD-enabled version yet. Maybe because it's in vendor/
now?
optimizeThis
option would be great. I think most users know the full list of their "base configs"; they have to list them all manually in their HTML code anyway.
PS: I've got some more questions, but I'll try to figure them out myself first, and ask them in separate issues if necessary.
Going to reopen this and I intend to properly fix it here in the next day or so.
(via http://questhub.io/realm/meta/quest/51c244646f612e795000000b)
Maybe I'm doing something wrong, but I can't figure out how mimosa chooses which files to optimize.
Here's a quick&dirty branch where I tried to convert my existing code to use mimosa. Basically, I did
mimosa config
and moved all JS and underscore templates toassets/javascripts
.Now, if I'm trying to do
mimosa build -o
, it attempts to optimizeapp.js
,setup.js
andvendors/backbone.js
. I understand why it choosessetup.js
(it's the main file which callsrequirejs.config
), but why app.js and why backbone.js?Optimizing
app.js
fails becausesetup.js
sets path for jquery, and app.js relies on that path. I tried to configurerequire/commonConfig
andrequire/optimize/mainConfigFile
, but that didn't help. I also tried to readsrc/tasks/register.coffee
(which seems to be choosing these files), but couldn't understand what's going on.