【发布时间】:2017-03-15 22:53:27
【问题描述】:
在一个简单的 Typescript 程序中,我使用 require 节点 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.config.js 文件中应用webpack.ContextReplacementPlugin。
这有点超出我的能力范围,但 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 执行此操作吗?
【问题讨论】:
-
你发现了吗?
-
是的,答案如下。
标签: node.js typescript webpack electron node-ffi