module App
open Fable.Import
let activate (ctx : vscode.ExtensionContext) =
printfn """Congratulations, your extension "fable-vscode-helloworld" is now active!"""
vscode.commands.registerCommand("extension.helloWorld", fun _ ->
let _ = vscode.window.showInformationMessage("Hello World!",[||])
null
)
|> ctx.subscriptions.Add
let deactivate () = ()
上面需要Fable.Import.VSCode
包。多亏了fable-splitter
的说明,我已经成功地用这里编译了上面的代码,但是我想坚持一个编译方案,所以我也希望用webpack
来编译。
var path = require("path");
module.exports = {
mode: "development",
entry: "./src/App.fsproj",
output: {
path: path.join(__dirname, "./public"),
filename: "bundle.js",
},
devServer: {
publicPath: "/",
contentBase: "./public",
port: 8080,
},
module: {
rules: [{
test: /\.fs(x|proj)?$/,
use: "fable-loader"
}]
}
}
这是我的webpack.config.js
。我所使用的项目模板是寓言文档中的标准模板。
ERROR in ./src/App.fs
Module not found: Error: Can't resolve 'vscode' in 'E:\Webdev\Fable\js-test\src'
@ ./src/App.fs 2:0-53 6:16-24 7:4-11
@ ./src/App.fsproj
当我尝试用webpack
构建它时,它会抱怨它无法解决vscode
。我在这里该怎么办?
发布于 2020-04-15 18:17:16
您需要将vscode
声明为外部依赖项,这样Webpack就会知道它不应该试图将扩展直接捆绑在代码中。需要时,将在运行时包含VSCode。
您需要将其添加到webpack.config.js
中。
externals: {
"vscode": "commonjs vscode",
}
https://stackoverflow.com/questions/61225751
复制相似问题