単純な 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でこれを行う方法はありますか?