You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
January 10, 2013 Following the yesterday’s post. This time, using PhantomJS and Grunt. Testem does pick up PhantomJS and can run against it. But, maybe some people just want to use Grunt because they use Grunt for something else such as for making a build. Setting up directories First, let’s create two directories: app and test. ‘app’ holds the application and ‘test’ of course contains test stuff.
r.js RequireJS用のmoduleをビルドする際にはr.jsを使います。 build.js この時にビルド設定の記述に使用するのがbuild.jsでこんな感じで書きます。 簡単な例だとこんなの ({ baseUrl:'./src', dir : './build', paths:{ jquery:"../lib/jquery-1.8.2", text:'../lib/plugins/text', underscore:'../lib/underscore-1.3.3' } }) 動的なbuild.js build.jsはJSONではなくてJSです。 JSなので処理を書くことが出来ます。 例えば関数その場実行を含む下記のbuild.jsは、上記のものと同じ設定を表します。 ({ baseUrl:'./src', dir : './build', paths:(function ()
REQUIRE JS JSの非同期ローディングとモジュール化を行うライブラリ 公式サイト 詳しくは、RequireJS実践編を参照 下記順番で読み込み(config-require.jsは自作。名前はなんでも良い) <script src="config-require.js"> <script data-main="main" src="require.js"> 非同期ローディングについて 下記を参考にconfig-require.jsを作成 設定値の詳細はこちらを参照 var require = { deps: ["some/module1", "my/module2", "a.js", "b.js"], callback: function(module1, module2) { //This function will be called when all the dependen
enchant.jsプログラミングでRequireJSを使うとなにが嬉しいの?どうやって使うの?という話。最初はenchant.jsをCommonJS/Modulesに合うように書き変えなきゃダメだと思っていたんですが、そんなことはないんですね。これは便利。 何が嬉しいの? 開発時にはゲームを複数のJSファイルに分割できるというメリットを、公開時にはゲームプレイに必要なダウンロード回数を減らせるというメリットを得られます。 Why Web Modules? 複雑なゲームじゃないしべつにgame.jsひとつで充分ですという場合には、はっきり言って不要なモノです。しかし長々と開発してたらクラス数が10を超えてきて超長いスクリプトになっちまったぜウォォという場合には、遠慮なくコードを分割統治できるというメリットは大きいでしょう。 enchant.jsとgame.jsを読み込む まずはrequir
In my previous post, I covered the structure of a Backbone.js application using RequireJS. The next thing (or if you are a TDD fan, the first thing) we do is to run some tests on it. According to Coda Hale: Writing tests for your code may not reduce the number of bugs, but it will make fixing the bugs you inevitably find easier. Obviously, we can take advantage of the AMD architecture, to help us
Writing Modular JavaScript With AMD, CommonJS & ES HarmonyのModules With Deferred Dependenciesが便利なので活用してる。 初期化処理が非同期処理でrequireしてきても即使えるとは限らない場合に使う。 モジュール側ではモジュールそのものではなくてpromiseを返しておいて、モジュールの実体が完成したらresolveで渡す。 使う側はrequireしてきたpromiseのthenメソッドのcallbackでモジュールの実体を受け取って使う。 // 何らかの非同期処理を経て初期化されるモジュール define('someModule',['jquery'],function($){ var dfd = $.Deferred(); setTimeout(function(){ // モジュールとして実際
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く