FAQ Database Discussion Community


How to use RequireJS optimizer in Play framework?

requirejs,webjars,requirejs-optimizer,playframework-2.4
As advertised, the rjs in Play can ensure that any JavaScript resources referenced from within a WebJar are automatically referenced from the jsdelivr CDN. In addition if any .min.js file is found then that will be used in place of .js. An added bonus here is that there is no...

Create session timeout warning for durandal single page application

javascript,model-view-controller,requirejs,single-page-application,durandal
I have a durandal/requirejs single page application. When a user sits idle, I need to display a warning to the user indicating that the session is about to time out. I have looked at several examples on the internet for asp.net apps, but can't find any examples for a single...

require js defining modules in html script tags

requirejs
I am trying to define a module for the initual configuration options of my app inside an script tag in my html. but I get the following error: Error: Module name "options" has not been loaded yet for context: _. Use require([]) http://requirejs.org/docs/errors.html#notloaded here is the html: <script src="Scripts/require.js" data-main="/Recruiter/temp-search/App/main"></script>...

RequireJS with CommonJS modules

javascript,requirejs,amd,commonjs
Using RequireJS with CommonJS modules, what happens when I do this: define(function(require, exports, module) { //Put traditional CommonJS module content here var simpleCommonJSModule = require('simple-commonjs-module'); module.exports = new String('foo'); return { //return empty object along with using module.exports } }); if I return something, I assume the module.exports will be...

can-model cannot getting data from .json file

javascript,json,requirejs,canjs,canjs-model
I am trying to implement MVC using AMD in canjs. For that I am using requirejs. This is my domains.json file: [ "1":{"uid": "1","urls": "domain1.abc.com"}, "2":{"uid": "2","urls": "domain2.abc.com"}, "3":{"uid": "3","urls": "domain3.abc.com"} ] This is my domainModel: define(['can'], function(can){ SearchModel= can.Model({ id: 'uid', findAll: 'GET /domains.json' },{}) return SearchModel; }) This...

When adding AMD support to a library, should it also list its dependencies in define()

javascript,requirejs,amd
I am looking to add AMD support to a library although don't fully understand it. I have the following code that adds AMD support: if (typeof define === "function" && define.amd) { define(["imagesloaded", "hammer"], defineSequence); } else { sequence = defineSequence(imagesLoaded, Hammer); } The library depends on third-party libraries imagesLoaded...

requirejs + angularjs code structure split in different files

javascript,angularjs,requirejs
I'm using requirejs and Angular and I'm trying to create an application structure that allows me to split every controller/services/directives etc in different files. This is the structure I'd like to achieve: src/ components/ Navigation/ index.js module.js NavigationController.js NavigationService.js In module.js I'd like to do something like this: define(['angular', './NavigationService',...

grunt-contrib- packages are officially supported by Grunt?

javascript,gruntjs,requirejs,r.js,grunt-contrib-requirejs
I'm about to use the RequireJs plugin for Grunt. I found out that there are two plugins with the same functionality: grunt-contrib-requirejs (https://github.com/gruntjs/grunt-contrib-requirejs) grunt-requirejs (https://github.com/asciidisco/grunt-requirejs) I am wondering if -contrib prefixed plugins are the trusted, maintained and officially supported ones by Grunt? Is this a pattern that developers should look...

Backbone with Multipage node app strategy

node.js,backbone.js,requirejs
I have a question regarding the node app that I want to build. Before starting on the development, I've written a clear document that splits up my app into different components: Home Search User profile Dashboard etc... Each of these modules may in turn consist of different submodules. As every...

Require Js - Seeking Hybrid implementation of the requirejs in “Not fully client side application”

javascript,requirejs
It has been couple of days that I am exploring the requirejs ( the JavaScript module loader for loading the modules and dependencies asynchronously). What I have understood is you need to have all your JavaScript libs or plugins (like Jquery etc) to be loaded in the require.config for their...

Load textext.js plugin with require.js

javascript,jquery,jquery-plugins,requirejs,jquery-textext
I'm trying to load textext.js jquery plugin, with one of it's plugins, textext tags. On my project, I'm using require.js in order to load all scripts with it's dependencies. As used for other scripts, I'm using a shim config on my main.js file: main.js require.config({ shin: { jquery: { exports:...

requirejs and ByteBuffer

javascript,requirejs
im an javascript newbie and google didnt helps: I tryed to load ByteBuffer.js in an require.js module: define(['js/ByteBufferAB'], function (ByteBufferAB) { var MessageBase = function () { this._version = 0; // unsinged int 16 bits this._dataType = ""; }; MessageBase.prototype.toBytes = function () { //console.log( new ByteBufferAB(58)); var headerBytes =...

Isomorphic JavaScript with RequireJS

javascript,node.js,requirejs,isomorphic-javascript
I have some isomorphic JavaScript. I am using RequireJS on the client side. (function() { 'use strict'; function wrapper(require) { var MyDep = require('my-dependency'); return function MyExportedFunction() { // ... }; } if ((typeof exports === 'object') && module) { module.exports = wrapper(require); // CommonJS } else if ((typeof define...

Require external module in Typescript internal module

requirejs,typescript,amd
As the title suggests I have an internal module in which I require an external module (in this case momentjs) If I just have the module definition and reference this in my other files it compiles fine but of course at runtime I get a 'moment is not defined' error....

RequireJS extract list of all modules

module,requirejs,dependencies
How can one extract a list of all modules from a project using RequireJS? I am interested in getting the structure of the project, looking at modules and their dependencies.

RequireJS, require method argument is null

requirejs
Im new to RequireJS framework and I'm having an annoying error. I have a file custom.js that define a module: define(function () { return ({ hello: function() { alert('hello'); } }); }); and in my script tag in an ASP.NET MVC view I have the following code: <script type="text/javascript"> $(document).ready(function...

node.js continues execution without waiting for a require to complete.

node.js,asynchronous,requirejs
I'm trying to access a variable in a required node file. However the file requiring it always continues without waiting for the variable to be set. How do I get app.coffee to wait before continuing? I have two files: db.coffee: databaseUrl = 'mongodb://localhost/db' mongoose = require('mongoose') mongoose.connect(databaseUrl) db = mongoose.connection...

Angular Multiple ngIncludes with Transclusion on Page Losing Scope(?)

javascript,angularjs,angularjs-directive,requirejs,angularjs-ng-include
I am trying to build a modular ngInclude. By this, I mean that the ngIncluded JSP will pull in all the dependencies it needs and recompile itself before rendering. This same file is used multiple times on a single page. The main page has several tabs - all of which...

Library duplication issue using Highcharts in Jaspersoft Studio

javascript,highcharts,requirejs
I have a problem with Highcharts libraries. I have created various charts with the Custom Visualization tool available in Jaspersoft Studio. They do not use all the same library, e.g. I have a Bubble Map chart which uses Highmaps.js and a Stock chart which uses Highstock.js. Every report seems to...

Using library extensions with TypeScript + requirejs

three.js,requirejs,typescript
I'm currently messing around with THREE.js and socket.io to make a little game - I'm wanting to use the OrbitControls extension for THREE.js (i've used it before in a non-TS project) for camera controls. The problem is that the client can't seem to find it (it compiles fine): Uncaught TypeError:...

Naming modules with RequireJS

javascript,requirejs
I am trying to figure out how to name modules without using the relative path of the module itself. For example: Instead of doing this: //module is defined in app/js/routers.js define('app/js/routers',['app/js/currentView'],function(currentView) { }); I would rather do this: //module is defined in app/js/routers.js define('routers',['app/js/currentView'],function(currentView) { }); is this possible or...

RequireJS and TypeScript Class - Cannot call function externally

javascript,requirejs,typescript
I am having a tough figuring out how to mix RequireJs and TypeScript. I am compiling TypeScript with the AMD option. The problem is, the function declared within an exported class is classified as "prototype". Is this normal? ModalHelper.ts: export class ModalHelper { saySomething = (something: String) => { alert(something);...

Typescript - RequireJS specify pathing in require.config

javascript,requirejs,typescript
I am creating a new set of web pages in an existing application. We are beginning to implement Typescript+RequireJS. I am trying to figure out how I can do a require call in typescript that uses a name rather than a path. All the pathing will be specified in the...

Show jQuery loading progress before page fully loaded

jquery,asp.net,requirejs,domready
I am using requireJS domReady plug in to show jQuery loading progress on asp.net web page. Here is the code that I am using, require(['domReady'], function (domReady) { domReady(function () { //Hide jQuery loading progress }); //Show jQuery loading progress }); Problem: jQuery loading progress is showing good, but it...

Why is Dojo build generating all it's dependencies next to the released dojo.js file?

javascript,dojo,requirejs
All I want is a bundled version of dojo with is the require loader, domReady, and query and nothing else. I have tried many release.profiles and experimented changing the config. I tried these too: http://dojotoolkit.org/reference-guide/1.8/build/customBase.html http://jamesthom.as/blog/2012/08/03/finding-nano/ This and many other examples generate the whole folder of dojo and all its...

Tightly coupled code with requireJS

javascript,jquery,requirejs
I have pretty rudimentary knowledge in javascript. I plan on implementing RequireJS in my application for dynamic script loading & dependency management. Going through an example In the example there are 4 js files purchase.js, products.js, credits.js. main.js. main.js initializes the flow. I understand main.js needs the require method. require(["purchase"],function(purchase){...

Trouble with require js shims and r.js

requirejs,grunt-contrib-requirejs,requirejs-optimizer
I'm having a few issues with r.js I'm hoping someone can shed some light on. Consider the following shim: shim: { plugin: ['jquery'], plugin2: ['jquery', 'plugin'] } And the following arbitrary plugins (note: they don't need to be jQuery plugins, but 2 must depend on 1). Plugin 1: (function ($)...

KnockoutJS custom component loader not executing `loadViewModel`

javascript,knockout.js,requirejs,knockout-components
Context I have been fiddling around and trying to create my own (just another) SPA framework. In this framework I've been trying to create a custom component loader to be able to do some dependency injection 'n stuff on the viewModels I'm loading. Used KnockoutJS version: 3.3.0 Problem The loadViewModel...

Why `init` of shim in my require.js configuration not called?

javascript,django,backbone.js,requirejs,csrf
Update: I was writing a small module to handle this csrf token problem in backbone until I got push notification of @Louis's answer. His answer is quite elegant and seems nice, but I'll leave a link to my backbone.csrf module github repo just for anyone who needs it. ==================================================================== I'm...

r.js requireJS. Must I modify my HTML? [duplicate]

requirejs,r.js
This question already has an answer here: Javascript requirejs in development but compiled in production 2 answers Using requireJS to load 4 JS files, my HTML markup looks like this : <script data-main="js/app" src="js/vendor/require.js"></script> I run r.js to compile files to main-built.js. How can I now ask requireJS to...

Difference between local and global require in RequireJS

javascript,requirejs
Using RequireJS, I don't believe I fully understand the difference between the following two different usages of 'require'. In this case, I am only talking about the browser, not node.js. One of my questions is: can I require certain dependencies synchronously on the front-end using RequireJS? first there is this:...

RequireJS local var not matching

javascript,requirejs
Can anyone explain why this might be the case? I am in a RequireJS module that has zero dependencies. I am trying to create a singleton that represents the view state, to avoid a global variable. But for some reason the getter that is trying to retrieve a property from...

How to integrate RequireJS module into AngularJS application?

javascript,angularjs,architecture,requirejs
I want to integrate RequireJS module into AngularJS application. Below you can see a sample code. How do I load Module from module.js in my app.js? Edit: look at this solution I posted as an answer myself. Do you have any comments about it? // module.js define('Module', [], function() {...

Require inside Q promise

javascript,requirejs,q
I need to use require inside Q structure Q.fcall(function () { console.log('1'); }).then(function () { console.log('2'); require(['myfile'], function () { console.log('2.1'); }); }).then(function () { console.log('3'); }); What I expect? 1 2 2.1 3 What I got? 1 2 3 2.1 Is it possible? How I should to rewrite construction?...

Multiple Codemirror instances

javascript,jquery,requirejs,codemirror
I can create and display multiple dynamic codemirror instances, but I CANT reference them with the below code. Think the issue is that I need to create a dynamic function name. (Not 100% on how to do so here) var function (somefilename, xml){ var instanceName = somefilename + 'Editor'; require([...

requirejs circular dependencies and function objects

javascript,requirejs,classloader,circular-dependency
Is it possible to differentiate between dependencies which are needed on structure build (like inheritance) and runtime dependencies (within a method call). A little example: 2 "classes": Father and Child which depend on each other Father.js define(['Child'], function (Child) { function Father() {}; Father.prototype.childs = []; Father.prototype.addChild = function (c)...

Webpack loading code split bundles on the fly

javascript,requirejs,webpack
So I want to split my application code into 3 bundles using webpack. I'm able to get my framework bundle loading and working, but I can't get the other two bundles to load on the fly. Heres my webpack config: var fs = require('fs'), path = require('path'), webpack = require('webpack'),...

Require JS Text Plugin Dynamic Parameter Issues

javascript,requirejs
I am trying to write a function that I can use to pull my templates with Require and its text plugin. I want to be able to call template('modules', 'login'); and have it load the desired template. define(function(require) { return function(path, file) { return require('lib/text!templates/ + path + '/' +...

“Module loading did not complete” without circular deps in requirejs

gruntjs,requirejs,r.js
[edit] I narrowed the issue to the lib three.js. The application does work, what doesn't work is the r.js optimizer, when I remove all references to three.js in my require process then r.js does the compiling ( but then the app is not working anymore ) I simply comment those...

Javascript Jasmine Testing: Prevent tested function to call function from object that was created within tested function

javascript,testing,requirejs,jasmine,spy
I want to test a Javascript function with Jasmine that has a structure like this: showEditUser: function (...) { // more code here... var editUserView = new EditUserView(); // more code here... editUserView.generate(...); } editUserView.generate() causes an error. That does not matter because I don't want to test it. But...

Uncaught ReferenceError: RSVP is not defined , error while using require.js with rsvp

javascript,jquery,requirejs,rsvp.js,rsvp-promise
I am working on a demo showing the error handling in promises using rsvp.js. Everything seemed fine, till I used the CDN url for rsvp.js in a tag. Now since I have require.js for module loading in my application, I tried loading the rsvp.js module via require js syntax. In...

AlmondJS - Require external url

javascript,requirejs,almond
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?...

Understanding AMD: how to handle response flow with a one-way module relationship

javascript,jquery,requirejs,amd
Consider, if you will, an app with a few unique views/states - let's call it a game. You have an overworld screen, a battle screen, a multiplayer interface, and maybe a minigame or two. For the sake of argument, there isn't a lot of code in common between each view,...

Scaling web applications with requirejs

javascript,web-applications,requirejs
I am building a js application based on RequireJs. Everything is working fine except one thing, after compiling it with r.js application is around 2.5Mb. And it does not have yet all the functionality available, i mean there is still room to work inside. And i am afraid that the...

Passing a Marionette Application through requirejs

backbone.js,requirejs,marionette
file structure app | |--scripts | | | |--home | | | | | |--index.js | | |--object.js | | |--router.js | | |--views.js | | | |--app.js | |--main.js How do I get the Router file: router.js require([ 'jquery', 'backbone', 'app', 'marionette'], function($,Backbone,UserAdmin) { return Backbone.Router.extend({ routes:{ "":"showIndex" },...

Output require() construct with AMD generation

requirejs,typescript,amd
I currently have a set of RequireJs modules defined as: require(['dep1', 'dep2'], function(dep2, dep2) { ... }); I'm looking to convert these into TypeScript modules, however the AMD generation outputs them with the define() construct: define(['dep1', 'dep2'], function(dep2, dep2) { ... }); I can see how they would essentially be...

Require.js and document.write()

javascript,jquery,html,requirejs,blockly
I want to load a .js file asynchronously using require.js, but what I get is this error: Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened. The lines producing this error are at the very...

Visual Studio 2015 RC + RequireJS + jQuery

jquery,requirejs,typescript,visual-studio-cordova
I'm using Visual Studio 2015RC + Cordova CLI 5.1.1 + TypeScript + RequireJS + jQuery . I'd like to change the location of my jquery.js file from the scripts folder to scripts/lib. I added a requirejs.config and changed the jQuery location. requirejs.config({ baseUrl: 'scripts/lib', paths: { jquery: 'jquery' } });...

How to load ace editor with requirejs from CDN?

javascript,requirejs,ace-editor
I am trying to load the ace editor from a CDN with requirejs. Here is a plunkr which illustrates my problem. Ace is not defined in the following case: requirejs.config({ paths: { ace: ['//cdnjs.cloudflare.com/ajax/libs/ace/1.1.9/ace'] } }) $('h1').text("loading ace..."); requirejs([ 'ace'], function(ace) { $('h1').text("ace loaded.") console.log(ace) ace.edit('#editor') return }) ...

Use jScrollPane JQuery plugin with RequireJS

javascript,jquery,requirejs,jscrollpane,jquery-jscrollpane
Currently JQuery is working fine with RequireJS. I now tried to use the jScrollPane plugin for JQuery. This plugin depends on the mousewheel plugin, so both have to be loaded. Since both plugins support AMD this shouldn't be a big problem. I tried multiple solutions including require(['jquery.jscrollpane','jquery.mousewheel'], function(JScrollPane) { $(function()...

RequireJS doesn't load JQuery if widget on page has loaded JQuery already

javascript,jquery,requirejs
I'm having some trouble with requirejs, jquery and an embeddable widget that I've written. The widget is loaded via a javascript (that contains a minified version of jQuery). The problem is that the host site is using requirejs and tries to load jquery. Somehow, requirejs seems to think that jquery...

Does {} consume less memory than [] for nested objects in Javascript?

javascript,browser,requirejs
I had some legacy JS code that creates a giant nested object structure with []. The code goes some like this var data = []; data ["first"] = []; data ["first"]["second"] = []; data ["first"]["second2"] = "hello"; It is about 250+ KB of javascript, which is fairly large. When I...

requirejs returns undefined without dependency

requirejs,undefined,marionette,circular-dependency
On some occasions, requirejs returns an undefined object to my module. I've looked at a number of posts and most of the answer are related to circular dependencies. However I could find none (I have checked several times). I apologize by advance for pasting a quantity of code that I've...

Require.js not loading Three.js

javascript,three.js,requirejs
So I have some generated JavaScript (from TypeScript): define(["require", "exports", "three", "jquery", "./test"], function (require, exports, THREE, jQuery, Test) { var Main = (function () { function Main() { this.container = jQuery('#test'); this.scene = new THREE.Scene(); ... This ends up with an error in the browser (on the last line...

How to use jquery ui with requireJS and knockout-sortable?

javascript,knockout.js,requirejs,knockout-sortable
I'm trying to use requireJS to manage dependencies in my first ever single-page javascript app. Having never used requireJS before, I'm struggling with something that I think is quit basic. My project uses knockoutJS, and an addon called knockout-sortable, which provides knockout bindings for the jquery ui 'sortable' plugin. It...

How to invoke RequireJS modules from old non-AMD Javascript code?

javascript,requirejs,amd
I am now trying to modulize my javascript code using RequireJS. I have 2 JS files (let's say A and B). A is a big file that has main code for my html page. B is a small utility library which is designed to be used by A and any...

How to reference an element that is altered by knockout component?

javascript,knockout.js,requirejs,dropzone.js
I'm trying to build a reusable Knockout.js upload component that consists of a Dropzone.js instantiation on a form element. AMDified Knockout Upload component: define(['knockout', 'dropzone', 'jquery', 'text!components/upload/upload.html'], function(ko, Dropzone, $, htmlString) { function UploadViewModel(params) { var self = this; self.dropzoneId = ko.observable(params.dropzoneId); self.postLocation = ko.observable(params.postLocation); Dropzone.options.uploadedFilesDropzone = { // Dropzone...

How does backbone with require.JS work?

javascript,backbone.js,requirejs
I am trying to understand how requireJS and backbone work. With this site when I open the DevTools in Chrome and opened a Sources Tab. I see a long list of folders/files (see image below) which seems to be the source code when it's uncompressed. However, I don't see it...

grunt requirejs multitask and multiple files

gruntjs,requirejs,grunt-requirejs
I'm using the following method to optimize multiple modules (optimizing multiple) and everything works fine when I am not using the multitask configuration. This works: 'requirejs': require('./build_config/requirejs.js')(grunt, config) This doesn't: 'requirejs': { 'task1': require('./build_config/requirejs.js')(grunt, config) } where requirejs.js is as follows: The gist...

Javascript Es6 default export

javascript,requirejs,export,ecmascript-6
I just want to double check since I am trying to do this ES6 export default: var Member = function(){} export { Member as default }; JShint is error-ing out with this syntax (es6 enabled) but I thought it was valid. Is this really invalid or what is a valid...

Typescript not exporting class for requirejs with internal modules

requirejs,typescript
TYPESCRIPT: import classModule = require("path/to/class"); module my.namespace { export class MyClass { constructor() { var someClass = new classModule.className(); } } } GENERATED JAVASCRIPT: define(["require", "exports", "path/to/class"], function (require, exports, classModule) { var my; (function (my) { var namespace; (function (namespace) { var MyClass = (function () { function MyClass...

How to do asynchronous initialization in a RequireJS module

javascript,asynchronous,requirejs
I'm trying to create a module which need needs to fetch data from a URL before initialization is complete. I suspect I am missing something obvious but how to a make RequireJS wait until my async call is complete before the require call is satisifed. // data module (function() {...

How to inject a third party library to an angular.js service

javascript,angularjs,requirejs
I am having trouble while trying to load the angular-cache library to my service. I used bower to add angular-cache to my project and it is successfully added. When I debug the service code on Chrome I see in the "Networks" tab that angular-cache is loaded: Name: angular-cache.js Method: GET...

Mismatched anonymous define() in Chrome extension content script

google-chrome-extension,requirejs,typescript
I'm trying to build a Chrome extension with TypeScript. The setup is quite simple: In manifest.json { "permissions": [ "webRequest", "webRequestBlocking", "tabs", "storage", "http://*/", "https://*/*" ], "content_scripts": [ { "matches": [ "http://*/*", "https://*/*" ], "js": [ "scripts/require.js", "scripts/require-cs.js", "scripts/main.js", "scripts/contentscript.js" ], "run_at": "document_end", "all_frames": true }], } In model.ts: export...

Karma: Executed 0 of 0 Error

requirejs,karma-runner
I think I have everything set up properly. I followed the specs of the Karma Tutorial for RequireJS, but everything I've tried seems to result in the same error. It appears that my test-main.js file is being loaded since a console.log() will fire. However, in the Object.keys loop, the files...

RequireJS - check if path is defined [duplicate]

javascript,requirejs
This question already has an answer here: How can I access configuration of Require.js 3 answers I have an angular.js application where I am lazy loading controllers and services in the resolve block of my state definitions (ui-router). Here is what I do: resolve: { loadDependencies: function ($q, $stateParams,...

how can i use require(“”); in javascript

javascript,firefox,plugins,requirejs,mozilla
i want to use a plugin in Firefox that it is in this. in this plugin tutorial use require function, and it is: require("sdk/preferences/service"); but i get error that require is not defined. so i search and download requireJS. but when attach this i get error module name sdk/preference/service has...

Difference between bower, browserify, requirejs, webpack?

javascript,requirejs,gulp,bower,browserify
I'm used to simple and small JS projects where the JS dependencies are concatenated and minified as part of the build process using something like gulp and the script tag in the html contains the hardcoded path to that minified JS file. It's not elegant and probably has several disadvantages,...

Unknown provider: ngMessagesProvider with require.js

angularjs,requirejs
I am trying to use ngMessages in my controller: I am setting up my require.js config: require({ // libraries dependencies (fallback support) paths: { jquery: [ 'vendor/jquery/2.1.3/jquery.min' ], bootstrap: [ 'vendor/bootstrap/3.3.2/js/bootstrap.min' ], angular: [ 'vendor/angular.js/1.3.11/angular.min' ], angularResource: [ 'vendor/angular.js/1.3.11/angular-resource.min' ], angularAnimate: [ 'vendor/angular.js/1.3.11/angular-animate.min' ], ngMessages: [ 'vendor/angular.js/1.3.11/angular-messages.min' ], uiBootstrap: [...

jquery window resize not working in requirejs

javascript,jquery,html,css,requirejs
I'm totally new to requirejs and started using it in my project. I have one problem when i use window resize event its not firing. Here, i have added my code. Please help me out from this issue. define(["jquery"], function($) { $(function() { set_screen(); }); function set_screen(){ var heroBannerHeight =...

Use requirejs modules as es6 module

javascript,requirejs,ecmascript-6,commonjs,es6-module-loader
I'm trying to migrate my project to ES6 modules, but I met an issue. I have 3rd party script that use modules with help of requirejs. Let name it 3rdParty.js. It was obtained via bower, so there is no ability and wish to update it. Is there any way to...

How to load a directive into a module after instantiating using requirejs

angularjs,requirejs,angular-amd
To describe my hurdle, A little back story. I was injecting all the requirejs path files(directives basically) which contains any directive to my main module in the app.js, which was working perfect. Its somewhat like define(['angularAMD', 'angular-route', 'angular-resource', 'angularTranslate', 'angularTranslateLoaderStaticFiles', 'bootstrap', 'angular-idle', 'loadingMaskDirective', 'multiselectDirective', 'treeview.directive', 'tabs', 'checklist.directive'], function(angularAMD) { var...

Leading Underscore transpiled wrong with es6 classes

javascript,requirejs,reactjs,ecmascript-6,jsx
I am experiencing a really weird behavior and can't even say which package to blame for it. My setup: RequireJS project with the JSXTransformer and the jsx! plugin I have an es6 class like this: define([ 'react' ], function( React ) { class MyComponent extends React.Component { myMethod() { otherObject.someMethod()._privateProp;...

can't get requirejs, angularjs and almond to work together

javascript,angularjs,gruntjs,requirejs,almond
I've been struggling with this all day, it seems like I'm the only one with this problem. everything works perfectly before compiling and even by compiling without setting: almond: true, wrap: true, And even with these settings grunt still works without an error. But angular never gets bootstrapped! If I...

Create a module with submodules

javascript,requirejs
I have a small homebrewed framework. I'm using this in several projects and I would like to bring that in a handy format for reusing it. I would like to organize the code as follows: Each prototype has its own file Each file is a require.js module I would like...

Jasmine test case in maven with requirejs

javascript,maven,requirejs,jasmine
I want to use jasmine for unit testing javascript application. My application uses requirejs. I found Jasmine maven plugin This plugin works great for non requirejs application. It also has requirejs template but i am unable to successfully run testcases with maven. I have written sample test case as require(['models/MyModel'],...

Using Asynchronous Module load in javascript library project

javascript,requirejs,amd
I am working on an javascript project which will be provided as a third-library. And there are a lot of modules and templates which is a waste of time and performance if loading them all at once. So I think use a module loader like requirejs maybe a good idea....

RequireJS module receives JSON from API server, returns undefined?

javascript,json,knockout.js,requirejs,durandal
I've done all sorts of reading on promises and module creation and I can't figure out why this won't work. I'm writing a script that takes a username and then uses a separate module to get user data from a 3rd party API. I can get everything to work fine...

Can't get “crossroads” to load as requirejs AMD module in typescript

requirejs,typescript,definitelytyped
I am trying to port a javascript app to typescript that uses requirejs. I am using the typedefinition from @mhegazy at DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped/tree/master/crossroads Typescript compiler is giving me the following error... error TS2307: Cannot find external module 'crossroads'. This did all work in javascript using "defines" instead. I just used...

$(window).bind('load' … ); not triggering

javascript,jquery,backbone.js,requirejs
I'm currently working at making a web application only open one instance. This is being done with cookies that are being set/checked when the app is loaded and removed when the app is closed. My logic for setting the cookies I've already worked out, but I'm having a problem getting...

Load minified files generated by WebEssentials with RequireJS

javascript,requirejs,typescript,bundling-and-minification
I used WebEssential tool to generate some minified version typescript files, so right now i have all the .min.js files. Now I want to use that minified files version on the project, but they was never loaded. I use to import modules like this: import Controller1 = require('ctls/Controller1'); but it...

Create custom mode of ace-editor without requireJS [closed]

requirejs,ace-editor
I want to create an angular service module can generate custom mode of ace-editor. But for creating custom mode of ace-editor, it used requireJS. I don't want to use it in my angular service module. So I wonder how to create custom mode of ace-editor without requireJS?

require js is not loading the modules from the configs

javascript,requirejs
I have the index.html as: <!DOCTYPE html> <html> <head> <script data-main="scripts/main" src="lib/require.js"></script> </head> <body> <h1>Example 1: basic usage</h1> </body> </html> and the main.js: requirejs.config({ waitSeconds: 200, paths: { "app": "app" } }); and the app.js: define(function () { alert('Hello World'); }); both main and app are under scripts folder. When...

Calling a function inside Require.js module with string var

javascript,requirejs
Can I call a function inside a Require.js module with the function name in a string ? define(['jquery', function( $ ) { var init = function() { var elems = {}; for( var x=0; x<$('.js-elem').length; x++ ) { elems[x] = { dom: { el: $('.js-elem').eq(x) }, get animation() { return...

How to load a merged JS file containing several modules with requireJs?

javascript,merge,requirejs
That's something I've struggled with for more than a year now, I don't get how we are supposed to load a JS file that contains several AMD modules at once to avoid making as many HTTP requests as there are JS files. Since we have to define each module separately...

Using requirejs optimizer node module with Gulp

requirejs,gulp,amd,r.js
There's gulp-requirejs plugin, but it's blacklisted with the following message: "use the require.js module directly". The docs are quite sparse, how would I best use it in conjunction with Gulp build task? In the docs there's an example: var requirejs = require('requirejs'); var config = { baseUrl: '../appDir/scripts', name: 'main',...

Creating/Accessing Global object with requirejs and backbonejs

javascript,object,backbone.js,requirejs,globals
This is presented in easy to understand fashion, so enjoy reading :) I have a backbone app which is initialised with main.js file like this: require([ 'backbone', 'app', 'models/session' ], function (Backbone, Application, SessionModel) { //new Application(); window.App = { session: new SessionModel() }; new Application(); Backbone.history.start(); }); As you...

Angular controller sporadically not loading

javascript,angularjs,requirejs,angularjs-scope
I have a website set up with RequireJS and Angular, but at seemingly random moments, it will decide to either not load part of the Javascript or not databind part of the angular code. The page in question has several different components on it with their own angular controllers. Everything...

angular.js loaded instead of angular.min.js with requirejs

javascript,angularjs,requirejs,webjars
I'm using Webjars to import AngularJS into my web project. For some reason the minified version of AngularJS won't be served even though I'm referencing those in my main. I was expecting to see angular.min.js and angular-route.min.js being loaded, but I'm seeing the regular angular.js and angular-route.js. What am I...

Executed 0 of 0 ERROR when running Karma on Cordova project

cordova,requirejs,karma-runner
I have an apache cordova project setup and I'm trying to use Karma for the first time. I've started the project like this: karma start test/karma.conf.js --verbose But all I'm getting is: INFO [karma]: Karma v0.12.36 server started at http://localhost:9876/ INFO [launcher]: Starting browser Chrome WARN [web-server]: 404: /favicon.ico INFO...

How to resolve multiple RequireJS config files from Webjars

javascript,spring,requirejs,webjars
In a spring-boot application i obtained several webjars (basically javascript,css and resource files in jar packages), all which are specified in a maven pom file. pom.xml <dependencies> ... <dependency> <groupId>org.webjars</groupId> <artifactId>requirejs</artifactId> <version>2.1.16</version> </dependency> <dependency> <groupId>org.webjars</groupId> <artifactId>angularjs</artifactId> <version>${angularjs.version}</version>...

$injector:modulerr even after defining module

angularjs,requirejs,angular-ui-router
With reference to this link : http://www.syntaxsuccess.com/viewarticle/angular-with-requirejs-amd-and-oclazyload and source code shared at : https://github.com/thelgevold/angular-lazy-load I am creating a simple angular app, which has one abstract state too. and getting the following error : Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.16/$injector/modulerr?p0=parentConnect&p1=E…8000%2Fparentconn%2Fbower_components%2Fangular%2Fangular.min.js%3A17%3A381) Folder Structure is : index.html <!DOCTYPE html>...

Load standard javascript files with requireJS

javascript,knockout.js,requirejs
I'm trying out requireJS in order to improve the loading of Javascript on an ASP.NET MVC app, using Knockout. I have some files defining custom ko bindings like that: (function (ko, bindings) { bindings.stopBinding = { init: function () { return { controlsDescendantBindings: false }; } }; bindings.anotherBinding = {...

JShint warning: jQuery plugin marked incorrectly 'defined but never used' in AMD

javascript,jquery,requirejs,amd,jshint
JSHint is throwing a "jQueryPlugin is defined but never used" error on the declaration of jQueryPlugin. How do I tell JSHint to either ignore this specific error or define jQueryPlugin in a way JSHint understands. define([ 'jquery', 'underscore', 'backbone', 'some-jquery-plugin' ], function ($, _, Backbone, jQueryPlugin) //here is the error...

Is there a way to conditional load a module via RequireJS based on whether or not the module 404s?

javascript,requirejs,amd
Problem: We currently have the following require.config: require.config({ paths: { lodash: '/embed/lodash', utils: '/embed/utils', analytics: '/external/analytics' } }); file paths that start with embed are guaranteed to exist. file paths that start with external may or may not be available, depending on the environment. If I begin my main.js with...

How to pass an object to an module in require.js?

javascript,requirejs
I have these js files: main.js: requirejs(['app']); app.js: define(['messages'], function (messages) { alert(messages.getHello()); }); messages.js: define(['global'],function () { var privateFn = global.getObj() return { getHello: function () { if(privateFn.hello == "test!") return 'Hello World'; } }; }); global.js: define(function () { var stateObj = {hello:"test!"}; return { getObj: function ()...

requirejs + bower, paths and dependencies within bower components

javascript,requirejs,bower,amd
I have done a lot of research but can't find the answer I am looking for, so here goes. I have a bower component which has its own dependencies: /vendor/bower_components/my_module/my_module.js /vendor/bower_components/my_module/dependency_1.js /vendor/bower_components/my_module/dependency_2.js Inside of my_module.js, it loads its dependencies using relative paths: define(["./dependency_1", "./dependency_2"], function (dep1, dep2) { ... });...

Using require would these result in the same object?

javascript,requirejs
In ./foo.js: return {}; In ./bar.js: var o1 = require('./foo'); var o2 = require('./foo'); console.log(o1 === o2); // true or false? ...

Using shim config with almond

javascript,requirejs,amd,almond
I am trying to shim certain modules for usage with almond like so: <script> requirejs.config({ shim: { 'jQuery': { exports: 'jQuery' }, //etc. </script> as certain scripts will already be included. However, this code: require(['jQuery', function($) { }); results in "undefined missing jQuery". If I shim jQuery like this: define('jQuery',...

GruntJS and custom task: require a RequireJS module

gruntjs,requirejs,grunt-contrib-requirejs
I am quite new with GruntJS and I wonder if it is possible to have a task that loads some RequireJs modules to process them and write the result within a JS file. I describe my scenario: I have a RequireJs based project with many files. I would like to...