requirejs

Do not copy source file when optimizing using requirejs

断了今生、忘了曾经 提交于 2019-12-07 06:35:20
问题 When using require.js (r.js) to optimize js code, all js source code are copied to destination directory(dir property). Is there a way (some configuration) to prevent requirejs to copy source files? 回答1: If you add removeCombined: true to your r.js build config the optimizer will remove (essentially not copy) all source files that were combined into your output module(s). Alternately, if you are referring to source files that are not part of the requireJS build at all, try using

Getting 'Uncaught Error: Script error' for a declared dependency when using r.js

ⅰ亾dé卋堺 提交于 2019-12-07 06:20:08
问题 I couldn't find an answer for my issue on SO or Github, so I am posting this: I created a repo for this issue: https://github.com/saviomuc/requireJSMultiPage I tried to set up require.js for a multipage project. All is fine when I am running the page. But when I try to optimize the files with r.js I am getting this error: GET http://localhost:63342/requirejs/www-build/js/library.js 404 (Not Found) require.js:7 Uncaught Error: Script error for: library http://requirejs.org/docs/errors.html

How to use multiple main.js files for RequireJs in Play Framework 2.1.1 Java?

旧城冷巷雨未停 提交于 2019-12-07 05:55:34
问题 I'm building a single-page app using, AngularJs + RequireJs in Play Framework 2.1.1. I have two application sitting inside the same Play server, admin dashboard and normal website. That's why I have two main.js files for Admin Dashboard and Normal website. The application structure looks like this. I got this from public/javascripts We want to separate the two pages that's why we have two main.js files. However, the problem I'm facing right now is that in the root main.js everything is fine.

Shim from grunt-contrib-requirejs not wrapping library

混江龙づ霸主 提交于 2019-12-07 05:54:09
问题 I am using requirejs and configuring my product artifacts, thus combining my libraries and setting up module dependencies between them to get the loading sequence appropriate using the grunt task for requirejs. I have no problem using runtime module injection while in my livereload server which has access to non-combined libraries. For the sake of clarity I have disabled all minification/uglification and turned on a js-beautify. requirejs: { dist: { // Options: https://github.com/jrburke/r.js

How to use AMD code completion with webstorm and requirejs?

浪子不回头ぞ 提交于 2019-12-07 03:16:36
问题 I have something like this define(function(require) { var Router = require('./router'); var Backbone = require('backbone'); var Log = require('log'); ... Apparently Webstorm is meant to support AMD modules but I can't get it to work, instead a get a massive list of properties from every .js file in the project. Has anyone had any luck getting Webstorm code completion / refactoring with requirejs modules? Update , I was able to get it working if I following the following construct define([

requirejs - Performance of multiple calls to require

时光总嘲笑我的痴心妄想 提交于 2019-12-07 03:13:07
问题 I'm wondering what is the proper approach for using RequireJS in a project with multiple modules, regarding performance of multiple require calls with less dependencies vs a single require with all the dependencies. Let's take the case where, for an app, I need to load some modules: gmaps, jquery, module1, module2, module3 . The use for some of the modules is quite independent. So, the question is which of the following alternatives is recommended (supposedly this code is the main module

Require.js Shim for loading JQuery UI and other JQuery Packages

落爺英雄遲暮 提交于 2019-12-07 03:06:17
问题 I am trying to load JQuery-Ui with a shim, but JQueryUi keeps timing out when I try to load it even when I know the path is correct. require.config({ paths: { jQuery: 'libs/jquery-wrapper', jQueryUi: 'libs/jquery-ui-min', jQuerySelectmenu: 'libs/jquery.ui.selectmenu', Underscore: 'libs/underscore-wrapper', Backbone: 'libs/backbone-wrapper', }, shim: {'Backbone': { //These script dependencies should be loaded before loading //backbone.js deps: ['Underscore', 'jQuery'], //Once loaded, use the

NodeJS and Javascript (requirejs) dependency injection

我怕爱的太早我们不能终老 提交于 2019-12-07 02:56:42
问题 I am currently using requirejs to manage module js/css dependencies. I'd like to discover the possibilities of having node do this via a centralized config file. So instead of manually doing something like define([ 'jquery' 'lib/somelib' 'views/someview'] within each module. I'd have node inject the dependencies ie require('moduleA').setDeps('jquery','lib/somelib','views/someview') Anyway, I'm interested in any projects looking at dependency injection for node. thanks 回答1: I've come up with a

How to handle requireJs timeout error?

瘦欲@ 提交于 2019-12-07 02:38:19
问题 I'm writing a mobile hybrid app using require.js as my loading framework. I have an issue with loading errors. What I'm trying to do is setup a fallback solution when the device is offline and I can't download the google maps API script that I need to display a map on the screen. All that I get is Uncaught Error: Load timeout for modules: async!http://maps.googleapis.com/maps/api/js?sensor=true but I'm not able to catch this error and provide an alternative implementation. Here is my gmaps

RequireJS and legacy application

﹥>﹥吖頭↗ 提交于 2019-12-07 02:38:09
问题 I have a legacy application and I have refactored parts of the application into separate backbone.marionette applications. I do not have the time or the budget to refactor the whole thing and I want my code to be easier to manage which made me think of requirejs. Most of the files are minified and munged together. Can I use requirejs for this type of hybrid solution where I can work on separate backbone modules and still access the existing javascript? 回答1: As someone who just recently