-
Notifications
You must be signed in to change notification settings - Fork 338
How to handle require.js in v2.0 ? #112
Comments
Throw a warning? IMO require.js should never be shipped to users. Every AMD app should take a trip through grunt-require to send the app through r.js and almond in place. |
I completely agree with Paul on this one. There's no reason require.js should be shipping with your app. R.js and Almond alleviate this need sufficiently. |
So are we saying that we need to deprecate the use of |
the softer option: throw a big ass warning. and tell people how to handle i'm in favor of the more draconian failure mode, to be honest. On Sun, May 12, 2013 at 6:48 AM, Frederick Ros notifications@github.comwrote:
|
To be honest, I'm on your side: this is one of the features I like the most with Go: no warnings, only errors. |
So, my proposal:
<!-- build:js js/app.min.js -->
<script data-main="js/main" src="js/vendor/require.js"></script>
<!-- -->
Does everyone agree on this ? |
Yup. Let's give it a go. Best if we can also point to a doc page on the yeoman site on how to do On Mon, May 13, 2013 at 8:22 PM, Frederick Ros notifications@github.comwrote:
|
Ok. This is my next task ;) Could someone hep me on the redaction of the 'why shipping require.js is not recommended' (at least get the cons ;)) |
Sgtm. Sorry for the mass mention but I would like to be sure this is the right move: |
@sindresorhus thanks for joining me. I agree with @paulirish and @addyosmani on not shipping RequireJS and optimizing through r.js + almond for the dist build. I'm currently working with grunt-contrib-requirejs + almond and everything works like a charm. But i think that maybe using Yeoman in dev server mode should leave the require.js script tag with the |
+1 for fast failing. If we have a chance to educate the user, let's use it! |
@alejandrogarciaiglesias Agreed for the development mode. When I said fast failing this is if the |
I haven't yet used usemin as our server code generates and bootstraps our initial page, that being said this project looks sweet and I'll take a look at using it for my next project. However, I hate to disagree with the legends @addyosmani & @paulirish on this one but I think it is a dangerous move to assume that using almond is always the best move... And error is extreme, perhaps a warning? In our application we use grunt-contrib-requirejs to build different submodules and then we run some static analysis to make sure the modules are optimized properly (no duplicates across built modules). Then we lazily load the modules as necessary. To assume that all apps should be fine without lazily loading code is a dangerous move particularly when you are talking about apps that are using a module system (usually they are bigger and consequently are more likely to require lazy loading code). It's not just the lazy loading of code, but code that uses multiple requirejs configurations or sub contexts. Just saying, "you must only use almond" tosses away a lot of the power and compelling reasons for using Require.js. |
@iammerrick Agreed, this setup using lazy loading sub-modules is also the way I currently work in a project. |
Support dropped. |
I can't really figure out the right way to make grunt-contrib-requirejs to call almond and work with grunt-usemin v2. No matter how I try, I can't get usemin to process my almondified main.js . I wouldn't dare to ask you if I hadn't researched quite a lot on my own before. Could you please provide some simple instructions on how you do it? I have really no clue on what needs to be changed in the workflow now that usemin doesn't support requirejs build blocks. My previous workflow is based on two-month old generator-webapp Gruntfile but I would want to use the new feature in grunt-usemin v2. |
So, is there a best practice for using grunt-usemin and grunt-contrib-requirejs? |
What I am doing for now:
Any suggestion? |
was this doc page ever written? I managed to use yeoman/grunt-bower-requirejs to generate a config file from my bower manifest.
Then with grunt-contrib-requirejs
The only thing left is processing the reference in index.html and for my particular edge case concatenating my output with some shims prior to minifcation / cache busting. Any suggestions? |
I don't understand the reason for this I have this HTML
With grunt I build my app with almond and save it on
And it works and I was not shipping require.js with my app. I didn't even knew usemin was aware I was using require. Now I updated to usemin 2.1 and my build process doesn't work anymore.
Is there anything I can do to build my project now? |
@amatiasq |
Was there ever an article/tutorial created on this topic? I'm still a bit baffled as to why my single file build script is looking for my module dependencies when I run index.html out of /dist. I'll also get errors around "define is not defined". I tried including requirejs as a path, but that appears to be actually including requirejs instead of going through the optimizer. I'm using grunt-requirejs and not grunt-contrib-requirejs (not sure what to use and when). In my scenario, main.js contains my require.config paths. Index.html
Grunt file:
|
I have the same issue from the default generator-backbone scaffolding. index.html
Gruntfile.js
grunt build results in
|
@DanielTate you can resolve the error? |
@lauradaniela No I am no longer using usemin |
In the scope of usemin 2.0, I'm rewriting part of
grunt-usemin
... One question that keeps bothering me is how to handlerequire.js
.Actually
require.js
is installed by bower inapp/components/requirejs/require.js
, but then how to handle it:concat
->uglifyjs
), and have it concatenated to other filescopy
target, and copied toscripts/vendor/require.js
I would tend to say that 2 is better but would really like to ear from you (also taking into account I do not know
require.js
vey well).The text was updated successfully, but these errors were encountered: