requirejs

Require.js Build Optimization Configuration

早过忘川 提交于 2019-12-11 09:10:23
问题 I'm having a hard time getting the require.js build just right. I have a main module and then the other pages/modules are lazy loaded. When it's done compiling, I have to fix the compiled dist/main.js or the app will load the compiled main module from the dist folder, but other modules are still loaded from the app folder. I have to change the require.config baseurl from /app to /dist . What do I need to reconfigure to get it to build correctly? Directory Structure ├── app │ ├── modules │ │ ├

Exporting CreateJS lib assets for use with require.js

ε祈祈猫儿з 提交于 2019-12-11 09:02:54
问题 I'm trying to use assets (vector, movieclips, etc.) exported from the Flash IDE for CreateJS but we are using require.js to manage our JS code so the exported lib JS is not directly compatible to be loaded with require.js Has anyone figured out what changes to do to the exported JS to adapt it for use with require.js? Here is an example of such an exported JS code: (function(lib, img, cjs) { var p; // shortcut to reference prototypes // stage content: (lib.Lib = function() { this.initialize()

Angularjs factory: errors on passing $scope,$route,$http?

喜夏-厌秋 提交于 2019-12-11 08:48:04
问题 Why my factory below keep throwing an error when the $scope, $route, $http are present? app.factory("factoryContacts",function($scope,$route,$http){ return { getContacts: function(){ return $http({ method: 'GET', url:'php/listContacts.php' }).then(function(response) { $scope.contacts = response.data; }); } }; }); can't I pass $scope, $route, $http into a factory? I tested with this basic one and it gives me the same error, app.provider('helloWorld', function($scope) { // note $scope is

Is it possible to run js-test-driver tests that uses requirejs modules?

人盡茶涼 提交于 2019-12-11 08:34:25
问题 I've been trying to use requirejs and js-test-driver along side, and I can't seen to get it working. I have a minimal configuration like this at the root : server: http://localhost:9876 load: - src/main/resources/web/resources/vendor/requirejs/require.js test: - src/test/js/*.js A "src/main/js/greeter.js" file defines a silly module : define(function(require) { myapp = {}; myapp.Greeter = function() { }; myapp.Greeter.prototype.greet = function(name) { return "Hello " + name + "!"; }; return

Functions within a loop using requirejs

谁说我不能喝 提交于 2019-12-11 08:25:31
问题 I'm having an issue with calling functions within a loop across different modules using requirejs. The function call within the loop resides in module A and executes a function in module B that fires off an Ajax request using jQuery. Each iteration of the loop fires off a different request with different arguments being passed to module B's function that fires off the Ajax request. When the success function of the Ajax request executes, I find that all my argument values are always the values

Change script tag type to 'text/ecmascript-6' or 'text/babel' when loading modules using requirejs

不问归期 提交于 2019-12-11 07:17:23
问题 I'm trying to use 'text/ecmascript-6' or 'text/babel' as the type when having requirejs load the Javascript files using script tags. How can I do that? For example <script type="text/babel" src="somefile.js"></script> 来源: https://stackoverflow.com/questions/28731256/change-script-tag-type-to-text-ecmascript-6-or-text-babel-when-loading-modul

dependency injection in context of backbone.js

扶醉桌前 提交于 2019-12-11 06:45:41
问题 I heard a lot about dependency injection(DI) in angular js. how we can achieve the same in backbone.js. I am browsing for the same but all articles are using requirejs for DI in backbone. How backbone is doing DI or How we can achieve DI in backbone ? 回答1: Backbone has not the concept of DI included into it. It's more a library than a framework. Normally tools like requirejs or browserify will do the dependecy injection for you. I prefer the CommonJS flavor of it, calling require("module")

Requirejs: AMD Module not defined

北慕城南 提交于 2019-12-11 06:20:06
问题 I want to use datepickk.js inside my module: even thought this plugin supports AMD I couldn't load it inside RequireJS: http://jsfiddle.net/numediaweb/5xbqqr0j/13/ // Config Object requirejs.config({ // Local Directory baseUrl: "/js", // Script Locations paths: { // Common Libraries "jquery": "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min", "datepickk": "//crsten.github.io/datepickk/dist/datepickk.min" } }); // Check Dependencies requirejs(['jquery', 'datepickk'], function ($,

How do I correctly include “require” in my angular 2 project?

徘徊边缘 提交于 2019-12-11 06:19:03
问题 I am still attempting to get the angular 2 code mirror module working within my angular 2 app. I've had some import issues that I've detailed here, that I seem to have gotten past, but now I've run into a new issue. My most recent stack trace is this Error: (SystemJS) require is not a function @http://localhost:8050/node_modules/ng2-codemirror/lib/codemirror.module.js:8:14 ZoneDelegate.prototype.invoke@http://localhost:8050/node_modules/zone.js/dist/zone.js:232:17 Zone.prototype.run@http:/

$injector:modulerr after r.js optimization, but not before

半城伤御伤魂 提交于 2019-12-11 05:59:18
问题 I'm using require.js with r.js to optimize. Pre-optimization, I have: // MainCtrl.js define(function () { return ["$scope", function ($scope) { console.log($scope); }]; }); // main.js require.config({ shim: { angular: { exports: "angular", }, }, paths: { angular: "lib/angular.min", }, }); require(["angular", "MainCtrl"], function (ng, MainCtrl) { console.log(ng); var app = ng.module("myapp", []); app.controller("MainCtrl", MainCtrl); }); My HTML is very simple; it just has ng-app=myapp in