2016-11-25 7 views
0

mocha-loaderプラグインでwebpackを使用します。mocha-loaderを使用したWebpack nextTickは関数ではありません

<!DOCTYPE html> 
<html> 
<head> 
    <title>Mocha</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
</head> 
<body> 
    <script src="./testing.js"></script> 
</body> 
</html> 

Mocha-:私は/testing.htmlファイルから testing.htmlをテストを実行

... 
target: 'web', 
entry: { 
    app: [path.resolve(applicationConfig.source.path, 'app.js')], 
    vendors: [path.resolve(applicationConfig.source.path, 'vendors.js')], 
    testing: 'mocha!' + path.resolve(applicationConfig.source.path, 'testing.js') 
}, 
... 

Uncaught TypeError: (intermediate value).nextTick is not a function(…) 

webpack.config.js:そして、私は、コンソールのエラーを持っていますローダーはstart.jsファイルを持っています:

process.nextTick(function() { 
    delete require.cache[module.id]; 
    if(typeof window !== "undefined" && window.mochaPhantomJS) 
     mochaPhantomJS.run(); 
    else 
     mocha.run(); 
}); 

はWebPACKの作業の後には、次のようになります。

({"env":{"NODE_ENV":"development"}}).nextTick(function() { 
    delete __webpack_require__.c[module.id]; 
    if(typeof window !== "undefined" && window.mochaPhantomJS) 
     mochaPhantomJS.run(); 
    else 
     mocha.run(); 
}); 

I'lはprocess.nextTick(https://gist.github.com/WebReflection/2953527)で使用するのポリフィルすることができますが、私は後に、プロセス変数の交換はできません。

答えて

0

私は

new webpack.DefinePlugin({ 
    'process.env': { 
     NODE_ENV: JSON.stringify('development') 
    }, 
    __DEV__: true 
}), 

とコード

を作品に

new webpack.DefinePlugin({ 
    process: { 
     env: { 
      NODE_ENV: JSON.stringify('development') 
     } 
    }, 
    __DEV__: true 
}), 

を置き換えます

関連する問題