私はwebpack 1.13.3を使用しています。_webpack_require空のモジュールオブジェクトを返します
_webpack_require空のモジュールオブジェクトを返します。 期待される結果は 'a.js' モジュールオブジェクトである..
ソースコード:
a.js
require.ensure([], function() {
var module = {};
module.init = function() {
console.log('a');
};
return module;
})
entry.js
require([], function() {
console.log(require('./a'))
require('./a').init();
})
index.htmlを
<script type="text/javascript" charset="utf-8" src="./main.js">
</script>
webpa ck.config.js
module.exports = {
entry: './entry.js',
output: {
filename: '[name].js'
}
}
webpack.config.jsでビルドし、ブラウザでindex.htmlを開きます。 エラーが表示されます。
はconsole.log((「./ A」が必要です))このコードのログだけで空のオブジェクト 『{}』
実際、私のレガシーコードはAMDを使用しています。私はAMDスタイルを使用しました。しかしthx! –
@mJane、webpackでは、AMDの代わりにAMDを使用できますが、AMDで変数をエクスポートする方法はありません。 – Ambroos