requirejs

requireJs / TypeScript, combine multiple classes into a single module?

一笑奈何 提交于 2020-01-05 17:54:17
问题 How can I combine multiple files into a single module ? Say I have a folder with multiple typescript classes e.g. app module1 foo1.ts foo2.ts .... module1.ts In any classes which uses any of the module1 defined classes, I would like to be able to include the dependencies using a single import like import {Foo1, Foo2} from "./module1/module1" rather than importing individual classes like import {Foo1} from "./module1/foo1" import {Foo2} from "./module1/foo2" How can I do this ? 回答1: Not sure

requireJs / TypeScript, combine multiple classes into a single module?

你离开我真会死。 提交于 2020-01-05 17:53:53
问题 How can I combine multiple files into a single module ? Say I have a folder with multiple typescript classes e.g. app module1 foo1.ts foo2.ts .... module1.ts In any classes which uses any of the module1 defined classes, I would like to be able to include the dependencies using a single import like import {Foo1, Foo2} from "./module1/module1" rather than importing individual classes like import {Foo1} from "./module1/foo1" import {Foo2} from "./module1/foo2" How can I do this ? 回答1: Not sure

'no such file' error when using grunt-requirejs compile

て烟熏妆下的殇ゞ 提交于 2020-01-05 12:23:32
问题 Since most issues with require.js build has to do with file structure and relative path reference, I created a repo here: https://github.com/ttback/requirejs-example for easier troubleshoot. The error is when i run grunt, I will get no such file or directory requirejs-example/src/js/bundle/js/bundle/utils.js This is due to the wrong baseUrl. I want it to be src/ but I can't set it since it goes to find the dependencies for src/js/bundle/main.js based on my Gruntfile. So the base is at src/js

How can have multiple Modules without repeat injections

家住魔仙堡 提交于 2020-01-05 08:43:45
问题 I have 2 applications app1 & app2 app1.js var app = angular.module("app1", ["ngRoute"]); app.config(['$routeProvider', function ($routeProvider) { $routeProvider.when('/view3', { templateUrl: 'http://localhost:40/partials/partial3.html', controller: 'MyCtrl1 as self' }); $routeProvider.otherwise({ redirectTo: '/view3' }); }]); app1 has ngRoute module, and route config app2.js var app = angular.module("app2", ["app1"]); app2 has app1 module Note: app1 run in localhost:40 & app2 in localhost:50

Cachebusting using grunt for multiple js files

流过昼夜 提交于 2020-01-05 08:34:11
问题 There are several questions on SO for grunt / cachebusting but I didn't find anything close enough to what I'm looking for. Hence, a new question.. Here is what I'm looking for. My Backbone/Marionette app's JS files are organized into module level folders. |- app |- modules |- module1 |- scripts |- models |- views |- templates |- module2 |- scripts |- models |- views |- templates |- index.html |- scripts |- app.js |- styles What I need is a way to concatenate / minify / uglify all of module1

Marionette js access to app from controller with requirejs

蓝咒 提交于 2020-01-05 04:56:21
问题 I want to get access to my main app instance from main controller to render new View. What i want to do is commented in controller/main.js code, as i understand this is circ dependency in require js, but i don't understand how to fix this file structure - controllers/main.js - models/ - templates/ - views/ - app.js - main.js - router.js main.js require.config({...}) require(['app'], function(app) { app.initialize().start(); }); app.js define(['jquery', 'underscore', 'backbone', 'marionette',

requirejs jquery multiple dependent non module jquery plugins like jquery-ui and jqGrid

北战南征 提交于 2020-01-05 03:35:29
问题 I am not able to order the non AMD modules with shim config. My shim config is like this. Even if I wanted to use require-jquery.js but still two non AMD modules will be jquery ui and jqGrid. jqGrid itself has a few plugins which must be loaded only when jqGrid has been loaded. requireconfig.js require.config({ baseUrl: '../jsp', paths: { app: '../js/app', jquerygrid: 'http://view.jqueryui.com/grid', lib: '../js/lib', plugins: '../js/plugins', jquery: '../js/lib/jquery-1.9.1', jqueryui: [

How to write RequireJS loader plugin with cache?

走远了吗. 提交于 2020-01-04 10:39:52
问题 I'm writing a RequireJS loader plugin. The plugin fetches html fragments cross domain via EasyXDM. It's invoked using the loader syntax, like this: 'html!someTemplate,#fragmentSelector' Since many repeat requests may occur, for example requesting different fragments from the same HTML document, I want to cache both the whole HTML document and the fragments. But I can't do any caching so far because I apparently have a gaping hole in my understanding of RequireJS loader plugins. I thought it

How to wait when data-main is loaded with Require.JS before executing script?

和自甴很熟 提交于 2020-01-04 05:48:13
问题 I'm having the following code: <script data-main="scripts/main" src="components/requirejs/require.js"></script> <script src="scripts/example1.js"></script> Inside example1 I'm doing a require for some components of which the path is supposed to be set in scripts/main . However, the path is not correctly set (judging by the console feedback) which leads me to believe that require.js hasn't finished loading files referenced in scripts/main . This all is pretty logical (async and all that), but

How to load Q library with Require.js?

我怕爱的太早我们不能终老 提交于 2020-01-04 05:41:13
问题 My library use kriskowal/Q promises library and now I'm trying to load (with requirejs) application that use my library so I put all paths and shims and my requirejs.config section looks like this: requirejs.config({ baseUrl: './', catchError: false, paths: { beril: '../engine/build/src/bundle', lodash: 'bower_components/lodash/lodash', three: 'bower_components/three.js/build/three', q: 'bower_components/q/q', }, shim: { lodash: { exports: '_' }, three: { exports: 'THREE' }, q: { exports: 'Q'