requirejs

TypeScript: Avoid require statements in compiled JavaScript

旧街凉风 提交于 2020-01-04 05:17:09
问题 In my TypeScript code I am using a third-party library called bunyan like so: private logger: bunyan.Logger = bunyan.createLogger({name: "MyClass"}); Because TypeScript cannot resolve the variable bunyan , I do this to make the TypeScript compiler work: import * as bunyan from "bunyan"; Unfortunately this causes the following JavaScript output: var bunyan = require("bunyan"); The require statement will not work in the browser (when not using a requirejs implementation), so I will receive:

Angular-Material with RequireJs

大城市里の小女人 提交于 2020-01-04 04:25:07
问题 today I'm tryng to configure angular material with requirejs but I receive an annoing problem: Error: ngMaterial requires HammerJS to be preloaded. This's my configurator file: require.config paths: jquery: "../bower_components/jquery/dist/jquery" domReady: "../bower_components/requirejs-domready/domReady" underscore: "../bower_components/underscore/underscore" store: "../bower_components/store-js/store" moment: "../bower_components/moment/min/moment-with-langs" jsonPath: "../libs/jsonpath-0

Handling load timeouts of a view in a Durandal app

五迷三道 提交于 2020-01-04 03:30:12
问题 I've got a Durandal app that will periodically timeout when attempting to load a view. Here's an example timeout error: Error: Load timeout for modules: text!views/primaryapplicants.html http://requirejs.org/docs/errors.html#timeout If you lookup the provided URL, it suggests a few possible issues: Script error in listed module Path configuration incorrect Multiple module IDs map to the same file None of these are my issue. It is a real, genuine timeout. For some reason it wasn't able to load

Grunt + Bower + Requirejs + Angular

泄露秘密 提交于 2020-01-04 01:02:14
http://www.tuicool.com/articles/ENbI7j3 时间 2014-07-27 22:08:46 Freewind.me 原文 http://freewind.me/blog/20140727/2739.html 现在web开发的趋势是前后端分离。前端采用某些js框架,后端采用某些语言提供restful API,两者以json格式进行数据交互。 如果后端采用node.js,则前后端可以使用同一种语言,共享某些可重用的Js代码,并共享构建工具。但很多时候我们可能采用别的语言,如ruby/java/scala等,此时前后端代码基本上是完全独立的。虽然大家都在同一个项目中,但可以分成互相独立的两块,并且前后端通常使用不同的构建工具。 比如当后端使用Scala时,我们会使用sbt进行项目构建,对scala代码进行编译、测试、打包等。它的专长是处理与scala相关的任务,但对于前端的支持比较弱。前端一些常见的任务,如js库的下载和管理、css文件的转换、js文件合并压缩、js测试的执行等,很难在sbt中找到好用的插件,而利用js世界里的工具来做反而更加方便一些。 我们项目组这几天正在讨论是否在项目中引入一些前端框架,还是直接用原生Javascript写。经过反复讨论和调研,最终决定引入AngularJs。但AngularJs的引入并不是单一的任务

reCaptcha + RequireJS

廉价感情. 提交于 2020-01-03 21:09:55
问题 How can I import recaptcha using requirejs. I already tryed several things and nothing works. I need do that to be able to render it by my own using the method render of reCaptcha once it has been loaded. require.config({ paths: { 'recaptcha': 'http://www.google.com/recaptcha/api' } }); require( ['recaptcha'], function( recaptcha ) { // do something with recaptcha // recaptcha.render /// at this point recaptcha is undefined console.log(recaptcha); }); <script src="https://cdnjs.cloudflare.com

How to stub Backbone View instantiated within another Views render method when Using RequireJS (and Jasmine / Sinon)

Deadly 提交于 2020-01-03 16:48:35
问题 I am attempting to write unit tests using Jasmine and Sion but I am struggling to find the equivalent of the following when using RequireJs to load modules: sinon.stub(window, "MyItemView"); When using RequireJs, I am unable to stub this way as MyItemView is not attached to the window. The following is an example of when I need stub the MyItemView: var MyView = Backbone.View.extend({ el: '#myElement', initialize : function() { var that = this; this.collection.fetch({ success : function() {

Load JavaScript and CSS files in folders in AngularJS

感情迁移 提交于 2020-01-03 13:10:53
问题 I have an AngularJS application and in the future, some developers in other teams will develop modules that will be installed as parts of it. So I defined the folder structure as below. www/ index.html app.js modules/ modulesA/ -- will be copied when module A was installed moduleA.js moduleA.css moduleA.partial.html modulesB/ -- will be copied when module B was installed moduleB.js moduleB.css moduleB.partial.html Now I have a problem. When user installed module A, how to let AngularJS (and

Load JavaScript and CSS files in folders in AngularJS

杀马特。学长 韩版系。学妹 提交于 2020-01-03 13:10:13
问题 I have an AngularJS application and in the future, some developers in other teams will develop modules that will be installed as parts of it. So I defined the folder structure as below. www/ index.html app.js modules/ modulesA/ -- will be copied when module A was installed moduleA.js moduleA.css moduleA.partial.html modulesB/ -- will be copied when module B was installed moduleB.js moduleB.css moduleB.partial.html Now I have a problem. When user installed module A, how to let AngularJS (and

RequireJS Optimization

微笑、不失礼 提交于 2020-01-02 20:29:10
问题 I`m using r.js to optimize my app, as i saw in several samples, i used build.json configuration file to config my optimization options. The problem is that when i set reference to the output javascript file after optimization I`m getting the following error in the browser: Uncaught ReferenceError: define is not defined main-built.js:14735 Looks like, all my app modules are exists but RequireJs is missing. This is my build.json configuration file: { "baseUrl": "../", "name": "src/modules/main"

require.js shim, export myOwnGlobal name

巧了我就是萌 提交于 2020-01-02 20:20:31
问题 I'm not sure about the use of "exports" on shim config, following the example on the requireJS API, I can use Backbone (B in capital letter) to export it to a global scope. This means that it will be a window object property. But I realized that I'm forced to use that name, and I can't export it by other reference name, ie: "MyGlobalBackbone" require.config({ paths: { backboneAlias:'backbone' }, shim : { backboneAlias : { deps : [ 'underscore', 'jquery-1.9.1' ], exports : 'MyGlobalBackbone' }