0

単純な Typescript プログラム Irequireノード FFI で

import  * as Electron   from  'electron';`
import  * as ffi        from  'ffi';`

その後

mylib = ffi.Library('libmoi', {
  'worker': [ 'string', [ 'string' ]  ],
  'test'  : [ 'string', []            ]
  } );

それをwebpackでリンクすると、

WARNING in ./~/bindings/bindings.js
Critical dependencies:
76:22-40 the request of a dependency is an expression
76:43-53 the request of a dependency is an expression
 @ ./~/bindings/bindings.js 76:22-40 76:43-53

問題は、FFI が動的であり、修正がファイルrequireに適用されるように思われることwebpack.ContextReplacementPluginです。webpack.config.js

これは私の手の届かないところにありますが、Angular の場合の例は次のとおりです。

plugins: [
      new webpack.ContextReplacementPlugin(
        // The (\\|\/) piece accounts for path separators in *nix and Windows
        /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
        root('./src') // location of your src
      )
  ]

FFIでこれを行う方法はありますか?

4

2 に答える 2

3

答えは次のとおりです: Johnny-Five リポジトリに関する github issue コメント

brodo の回答から引用すると、これは webpack が「バインディング」などで混乱するのを防ぐために行うことです。

... the webpack config looks like this:

module.exports = {
  plugins: [
    new webpack.ContextReplacementPlugin(/bindings$/, /^$/)
  ],
  externals: ["bindings"]
}
于 2016-11-05T21:24:18.037 に答える