私のプロジェクトでは、gulp を使用してタスクを実行し、webpack を使用して js モジュールをコンパイルし、babel ローダーを使用して反応と ES6 を変換します。次に、リレー変換を追加します。私はこの指示に従いました: https://facebook.github.io/relay/docs/guides-babel-plugin.html#advanced-usageしかし、彼らは正しくないようです。
ちょっとしたリバース エンジニアリングを行う必要があり、次の gulp タスクを作成しました。
gulp.task('js', () => {
// Compile babel (react)
gulp.src(paths.js)
.pipe(er(webpack({
module: {
plugins: [
new require('webpack/lib/ProvidePlugin')({
React: "React",
Relay: 'Relay'
})
],
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
loader: 'babel',
query: {
presets: ['es2015', 'stage-0', 'react'],
plugins: [require('babel-relay-plugin')(require(paths.db_schema).data)]
}
}
]
},
output: {
filename: paths.js_output
}
})))
.pipe(gulp.dest(paths.dist));
});
今、私は処理されたすべてのファイルに対してこのようなエラーを受け取ります:
ERROR in (filename)
Module build failed: TypeError: Falsy value found in plugins
at d:\Node\organize.me\node_modules\babel-core\lib\transformation\file\options\option-manager.js:187:15
at Array.map (native)
at Function.normalisePlugins (d:\Node\organize.me\node_modules\babel-core\lib\transformation\file\options\option-manager.js:182:20)
at OptionManager.mergeOptions (d:\Node\organize.me\node_modules\babel-core\lib\transformation\file\options\option-manager.js:298:36)
at OptionManager.init (d:\Node\organize.me\node_modules\babel-core\lib\transformation\file\options\option-manager.js:481:10)
at File.initOptions (d:\Node\organize.me\node_modules\babel-core\lib\transformation\file\index.js:211:75)
at new File (d:\Node\organize.me\node_modules\babel-core\lib\transformation\file\index.js:129:22)
at Pipeline.transform (d:\Node\organize.me\node_modules\babel-core\lib\transformation\pipeline.js:48:16)
at transpile (d:\Node\organize.me\node_modules\babel-loader\index.js:14:22)
at Object.module.exports (d:\Node\organize.me\node_modules\babel-loader\index.js:88:12)
@ multi main
私はさらにリバースエンジニアリングを行いました.プラグインの配列は、[ null ]
その行を
plugins: [new (require('babel-relay-plugin')(require(paths.db_schema).data))()]
エラーが発生します
TypeError: Cannot read property 'Plugin' of undefined
では、どうすればgulp、webpack、babel、relayを連携させることができますか? ありがとう。