2017-02-09 6 views
1

私は開発時にブラウザにGoogleクロージャモジュールをロードするだけで、高度なコンパイルは必要ありません。Google closure base.js&modules

私のindex.jsが含まれています

goog.module("Widgets.index"); 

var Widgets$app = goog.require("Widgets.app"); 
/* rest of the code */ 

を私のindex.htmlには、次のものが含まれています

<script src="closure/base.js"></script> 
<script src="index.js"></script> 

私は私のコンソールで、次を得る:

Module Widgets.index has been loaded incorrectly. 
Note, modules cannot be loaded as normal scripts. 
They require some kind of pre-processing step 

私はどのようにindex.jsを前処理しますか? 私はちょうど私のブラウザでいくつかの簡単なGoogleモジュールをロードしたい、これは開発時間です。

答えて

1

エントリポイントはスクリプトとしてページに含まれていますが、モジュールとして定義されています。エラーメッセージがあなたに伝えていることです。代わりに:

index.js

goog.provide("Widgets.index"); 

var Widgets$app = goog.require("Widgets.app"); 
/* rest of the code */ 
関連する問題