requirejs

Circular Dependencies for a web app using backbone.marionette and requireJs

浪子不回头ぞ 提交于 2019-12-09 10:43:52
问题 I am in the following situation. I am using requireJs to loads module and I don't want to use global variables. The main.js is responsible to load the router. Then the router loads the app and the app loads several subApps. After everything has been initialised, the subApps needs the router for making router.navigate . Here the schema: main.js -> router -> app -> subApp -> router Then I have a problem of Circular Dependencies and for that reason the router in subApp will be undefined. What is

RequireJs: Use autoloading-deps with shim

独自空忆成欢 提交于 2019-12-09 10:43:31
问题 I have defined a RequireJs configuration which defines paths and shims: require.config({ // define application bootstrap deps: ["main"], // define library shortcuts paths: { app: "app" , jquery: "lib/jquery" , underscore: "lib/underscore" , backbone: "lib/backbone" , bootstrap: "lib/bootstrap" }, // define library dependencies shim: { jquery: { exports: "$" }, underscore: { exports: "_" }, backbone: { deps: ["underscore", "jquery"], exports: "Backbone" }, bootstrap: { deps: ['jquery'],

How to write a module that works with Node.js, RequireJS as well as without them

烂漫一生 提交于 2019-12-09 09:28:40
问题 I am working on a JavaScript library for JSON/XML processing. My library works in browser as well as Node.js (with xmldom and xmlhttprequest modules). One of the users recently asked for RequireJS support. I have taken a look at the RequireJS/AMD thing and think it is a good approach so I'd like to provide this. However I'd like to retain the portability: my library must work in browsers (with and without RequireJS) as well as Node.js. And in the browser environment I don't depend on xmldom

How to synchronise/organise modules using requirejs and Backbone.Marionette

回眸只為那壹抹淺笑 提交于 2019-12-09 07:04:53
问题 I organised the file structure of my web app, which is using RequireJs and Backbone.Marionette,in this way: |- main.js |- app.js |- /subapp1 |- subapp1.js |- subapp1.router.js |- /subapp2 |- subapp2.js |- subapp2.router.js |- /colections |- /views To loads the modules I use requireJs. Here's my code, for each module I put some questions. // main.js define([ 'app', 'subapp1/subapp1.router', 'subapp2/subapp2.router' ], function (app) { "use strict"; app.start(); }); Questions: 1) Is right to

How to efficiently debug webpack applications?

这一生的挚爱 提交于 2019-12-09 06:35:00
问题 I am trying to adopt webpack dev server in my project. I know it's quite widely adopted, so it surprised me that debugging the application seems to be quite hard. Since webpack by default produces a single giant bundle, source maps are a must. I have a big problem with them: Depending on devtool mode, source maps are either slow to parse ( eval ) or not used to map some stack traces ( eval-source-map ), e.g there are times the entire stack trace looks like this: at eval (eval at <anonymous>

require js remove definition to force reload

别说谁变了你拦得住时间么 提交于 2019-12-09 06:07:13
问题 For testing purposes I am trying to remove some amd modules and reload updated versions from the server - with the goal of not refreshing the browser. I am currently doing the following but the browser still doesn't reload the items from the network. var scripts = document.getElementsByTagName('script'); var context = require.s.contexts['_']; for (var key in context.defined) { if(key.indexOf("tests")>-1){ requirejs.undef(key); for (var i = scripts.length - 1; i >= 0; i--) { var script =

Cordova 2.4.0 or 2.5.0 or 2.6.0 and requirejs

十年热恋 提交于 2019-12-09 06:04:36
问题 Cordova 2.4.0 and up supports AMD for loading into javascript. I am specifically looking to use Cordova 2.5.0 with the latest version of RequireJS, backbone, jquery, jquery mobile. I have yet to see any tutorial or posting about how to use the new version of Cordova properly with with requirejs. I do see tons of posts about how to incorporate Cordova and requirejs back when Cordova did not support AMD (2.3.0 and prior). If anyone can post or point me to a simple example of this, it would be

Angularjs: ocLazyLoad vs Requirejs

浪子不回头ぞ 提交于 2019-12-09 04:35:42
问题 I'm working on a big angluar project and obviously we need a way to lazy load our scripts. I've worked with require.js before and it's quite good, but the problem is that after we concatenating and minifying our files, we got a 1.5M js file. So i just encountered OcLazyload and it looks promising but i saw a lot of examples on the web that use both require and ocLazyLoad, I'm a bit confused as to why you would want to use both. Aren't they both doing the same thing? 回答1: You need both

How to reference the bundled js files (asp.net mvc4) in Require.js?

回眸只為那壹抹淺笑 提交于 2019-12-09 04:27:50
问题 I have been studying John Papa's pluralsight course on SPA. In his main.js , he gave a name to each js library which is included in the bundle. (function () { var root = this; define3rdPartyModules(); function define3rdPartyModules() { // These are already loaded via bundles. // We define them and put them in the root object. define('jquery', [], function () { return root.jQuery; }); define('ko', [], function () { return root.ko; }); define('amplify', [], function () { return root.amplify; })

Moment Timezone returning Uncaught TypeError on load

余生颓废 提交于 2019-12-08 21:36:44
问题 I am working on implementing Moment Timezone into a Django application in order to correct for users accessing it from different time zones, and I am running into an error when importing the files through Require.js. moment.js, moment-timezone.js, and moment-timezone-data.js are all loading, but when my script runs and tries to initiate them, moment-timezone.js and moment-timezone-data.js throw Uncaught TypeErrors. My moment-timezone-data.js file is copy-pasted from the Moment.js timezone