requirejs

If external typescript modules don't have a module name, how do you avoid naming conflicts?

亡梦爱人 提交于 2019-12-12 01:33:05
问题 This is a follow-on (sort of) to the question about the differences between internal and external modules. I want to use external modules as we're going to have a very large program. The problem is, if I create a class rectangle.ts: export class Rectangle { public x : number; public y : number; public width : number; public height : number; } And then access it using: import rectangle = require("rectangle"); // or is it "import rectangle = module("rectangle");"? var rect = new rectangle

Calling a TypeScript module from javascript via RequireJS

a 夏天 提交于 2019-12-12 01:07:16
问题 It looks like I have to do full naming when accessing a TypeScript module in javascript. Is this correct? My TypeScript is: export module App.editor.menu { export class File { static isOpenEnabled() { return false; } static openClicked() { debugger; } } } And my javascript is: Ext.onReady(function () { define(["../../scripts/ribbon", "./menu-handler"], function (ribbon, handler) { And I have to call "handler.App.editor.menu.File.isOpenEnabled()" instead of "handler.isOpenEnabled()" All the

RequireJS data-main module callback not invoked

有些话、适合烂在心里 提交于 2019-12-12 01:03:57
问题 My app: define(function bringTheAction() { console.log('Loaded!'); }); is optimised and loaded using data-main: <script data-main="src/app" src="lib/require.js"></script> and RequireJS does load the file: <script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="app" src="src/app.js"></script> however, the bringTheAction callback is never invoked and my app just sits idly. I can kick things off by doing require(['src/app']); in the console or by

Loading Backbone.Relational using Use! plugin

∥☆過路亽.° 提交于 2019-12-12 00:36:37
问题 Backbone Relational is not an AMD compliant library, so I've gone ahead and found the use plugin to ensure underscore and backbone are both loaded as dependencies. Here is my config file require.config({ baseUrl: '../global/js', paths: { use: 'libs/utilities/use', jquery: 'libs/jquery/jquery-min', underscore: 'libs/underscore/underscore-min', backbone: 'libs/backbone/backbone-optamd3-min', text: 'libs/require/text', relational: 'libs/backbone/backbone-relational' }, use: { "relational": {

using requireJS for plugin that exports multiple function to jquery

a 夏天 提交于 2019-12-12 00:11:42
问题 I'm trying to use requireJS to add this library/plug-in to jquery. I've looked at the documentation, and other S.O. questions, and I still can't figure out what's going wrong. Using backbone and require as an example: I'm pretty sure I need to use shim in my main.js file. I'm also pretty sure that I need to still load the plug-in in the particular file I want to use it in (Even though I don't actually use the rangyInputs object in the body of the function) (which I do for backbone). Really, I

Angular-Jasmine, loading json

早过忘川 提交于 2019-12-11 23:33:43
问题 I am trying to load json from local folder and then feed it into function to test it. Here is what I am trying to do: it('should be able to use treatExpResultJSON() function to treat incoming JSON', function() { require(['./jsonSampleData.json'], function(json){ expect(dirService.treatExpResultJSON(json)).not.toBeNull(); expect(dirService.treatExpResultJSON(json)).not.toBeUndefined(); console.log(json); console.log("Testing json passed!"); }); }); expect is not working inside the require

Load modules dynamically with Require.js

最后都变了- 提交于 2019-12-11 23:22:52
问题 I am trying to load modules dynamically as described at the beginning of this post: Reference link Here is my scripts/main.js require.config({ baseUrl: 'scripts', paths: { jquery: 'lib/jquery-2.0.3' }, config: { 'main': { modules: ['mod1', 'mod2', 'mod3'] } } }); require(function(require, exports, module) { console.log("Loading modules"); require(module.config().modules); }); When main.js gets loaded, code inside the outer require function never gets executed and "Loading modules" never gets

Knockout.js mapping plugin with require.js

主宰稳场 提交于 2019-12-11 22:46:10
问题 What is the standard way of loading mapping plugin in require.js ? Below is my config.js (require.js config file) require.config({ // Initialize the application with the main application file. deps: ["app"], paths:{ // JavaScript folders. libs: "lib", plugins: "lib/plugin", templates: "../templates", // Libraries. jquery: "lib/jquery-1.7.2.min", underscore: "lib/lodash", text: 'text', order: 'order', knockout: "lib/knockout", knockoutmapping: "lib/plugin/knockout-mapping" }, shim:{ underscore

requireJS sequential execution for non-AMD js files

纵饮孤独 提交于 2019-12-11 22:38:58
问题 am trying to bundle my javascripts using requirejs and build on top of it. There are some existing js files that has been developed for UI manipulation and library use. These js files, need to be included right after jquery includes and it also does things for social media widgets in the site. any who, I wrote the below code to try and bundle them to be executed when site is loaded, for some reason, I can see them loading in the firebug network. But the code within is failing because its

Overcoming RequireJS's '.js' extension adding in cache/proxy environments

拟墨画扇 提交于 2019-12-11 21:00:36
问题 RequireJS automatically adds a '.js' extension to each module name, and a known hack is to add a ? at the end, as detailed here and here. The problem is, that adding a question mark means cache and proxy servers will usually conclude these are dynamic files and not cache them. I guess it's configurable if I control these cache/proxy servers but between my server and the client there is potentially a downstream of proxy servers in between which is beyond my control. So, is there any other way