如何在没有 "wrapper: false" 的情况下通过 brunch 访问包装到命名空间中的函数?

How can I access a function wrapped into a namespace by brunch without "wrapper: false"?

我的早午餐配置:

npm: {
  enabled: true,
  whitelist: ["jquery"],
  globals: {
    $: "jquery",
    jQuery: "jquery"
  }
}

在一个简单的 html static 网络应用程序中,我可以非常轻松地使用 x-editable。但是,在我的网络框架(长生不老药)中,出于某种原因我不得不使用早午餐,这段代码不再有效:

$.fn.editable.defaults.mode = "popup";
$(".editable").editable();

因为 X-editable 被

包装成一个函数
 require.register("web/static/js/bootstrap-editable.min.js", function(exports, require, module) {

以及其他 js 文件中的其他功能。

我尝试了不同的方法来访问它但无济于事,例如:

$(".editable").require("web/static/js/bootstrap-editable.min.js").editable(); 
// note that $ is visible here

如何在不使用早午餐配置中的标志 "wrapper: false" 的情况下让它工作?

问题是关于 x-editable 的,但总的来说我想知道如何在早午餐中与其他 js 库一起处理此类问题。

您应该可以 import/require 图书馆。这将执行代码(在本例中注册 JQuery 插件)并允许您使用它。

import "web/static/js/bootstrap-editable.min.js"
$.fn.editable.defaults.mode = "popup";
$(".editable").editable();