almond

Why do concatenated RequireJS AMD modules need a loader?

我与影子孤独终老i 提交于 2019-12-20 08:28:19
问题 We love RequireJS and AMD during development, where we can edit a module, hit reload in our browser, and immediately see the result. But when it comes time to concatenate our modules into a single file for production deployment, there apparently has to be an AMD loader still present, whether that loader is RequireJS itself or its smaller partner “almond” as explained here: http://requirejs.org/docs/faq-optimization.html#wrap My confusion is: why is a loader necessary at all? Unless you have

AlmondJS - Require external url

独自空忆成欢 提交于 2019-12-20 05:37:45
问题 In one of my AMD modules I have require(["//google-analytics.com/analytics.js"]); It works with requireJS, but, when using almond, I get "Uncaught Error: undefined missing //google-analytics.com/analytics.js" error. Does this mean almond does not support requiring external scripts? 回答1: Does this mean almond does not support requiring external scripts? Yes, that's exactly what it means. From the "Restrictions" section , very first item: optimize all the modules into one file -- no dynamic

RequireJS modules loading out of order when loading one module into another

我怕爱的太早我们不能终老 提交于 2019-12-11 04:07:14
问题 I have written a web application which uses requirejs for AMD: require(dependencies, function(dependencies) { (function($) { $.fn.plugin = function(options) { return this; }; })(window.jQuery); }); I then used almond and r.js to compile it into a single javascript file, using the build config: ({ baseUrl: ".", paths: { 'jquery' : 'vendor/jquery-1.9.1.min' 'almond' : "../node_modules/almond/almond" }, name : "almond", include : "main", out : "plugin.js", wrap : true }) Next, I want to use this

Using almond with grunt-contrib-requirejs

邮差的信 提交于 2019-12-07 02:34:23
问题 I'm trying to set up a gruntfile that utilizes requirejs and almond. The docs suggest it should be really easy, and following their lead, I tried: requirejs: { compile: { options: { baseUrl: "tmp", mainConfigFile: "tmp/main.js", name: "../bower_components/almond/almond", out: "tmp/<%= pkg.name %>.js" } } } Unfortunately, this approach compiles almond.js rather than my actual source. Am I getting something wrong? How do I automate almond along with requirejs? 回答1: The trick is to use include:

Using r.js to package a SPA application that loads views using 'text'

余生颓废 提交于 2019-12-05 16:05:07
问题 I'm attempting to build a SPA application (requirejs, durandal 2, knockout) into a single main-build.js file using grunt, and I'm running into serious issues with the 'text' plugin that durandal is using to load my views. In dev, I'm successfully using 'text' to load views dynamically as per the standard way of building durandal apps. The difference is that I need to do some server side templating for the views and so they are actually being dynamically generated. With that in mind I'd like

Using almond with grunt-contrib-requirejs

与世无争的帅哥 提交于 2019-12-05 06:32:59
I'm trying to set up a gruntfile that utilizes requirejs and almond. The docs suggest it should be really easy, and following their lead, I tried: requirejs: { compile: { options: { baseUrl: "tmp", mainConfigFile: "tmp/main.js", name: "../bower_components/almond/almond", out: "tmp/<%= pkg.name %>.js" } } } Unfortunately, this approach compiles almond.js rather than my actual source. Am I getting something wrong? How do I automate almond along with requirejs? The trick is to use include : requirejs: { compile: { options: { baseUrl: "tmp", mainConfigFile: "tmp/main.js", include: "main", name: ".

Inline require() working in requirejs but not with optimized almond build

孤者浪人 提交于 2019-12-03 17:03:09
问题 As the title says my inline require calls are working in a non-optimized requirejs run but not working when built with grunt and almondjs. Uncaught Error: undefined missing views/some/view The top of any file might be: define( ['jquery', 'app'], function($, App) { and later on based on business logic I want to be able to require another file require(['views/some/view'], function(SomeView){ console.log(SomeView); }); I tried the alternative syntax as well: var SomeView= require('views/some

Inline require() working in requirejs but not with optimized almond build

血红的双手。 提交于 2019-12-03 06:02:46
As the title says my inline require calls are working in a non-optimized requirejs run but not working when built with grunt and almondjs. Uncaught Error: undefined missing views/some/view The top of any file might be: define( ['jquery', 'app'], function($, App) { and later on based on business logic I want to be able to require another file require(['views/some/view'], function(SomeView){ console.log(SomeView); }); I tried the alternative syntax as well: var SomeView= require('views/some/view'); And this all works using an unbuilt requirejs version. But again it fails when I build it with

Why do concatenated RequireJS AMD modules need a loader?

南楼画角 提交于 2019-12-02 17:16:59
We love RequireJS and AMD during development, where we can edit a module, hit reload in our browser, and immediately see the result. But when it comes time to concatenate our modules into a single file for production deployment, there apparently has to be an AMD loader still present, whether that loader is RequireJS itself or its smaller partner “almond” as explained here: http://requirejs.org/docs/faq-optimization.html#wrap My confusion is: why is a loader necessary at all? Unless you have very unusual circumstances that make it necessary for you to make require() calls inside of your modules

AlmondJS - Require external url

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 03:02:42
In one of my AMD modules I have require(["//google-analytics.com/analytics.js"]); It works with requireJS, but, when using almond, I get "Uncaught Error: undefined missing //google-analytics.com/analytics.js" error. Does this mean almond does not support requiring external scripts? Does this mean almond does not support requiring external scripts? Yes, that's exactly what it means. From the "Restrictions" section , very first item: optimize all the modules into one file -- no dynamic code loading. (Emphasis added.) Just read one of the almondjs authors comment on github - looks like external