如何在使用 RequireJS 时禁用 RactiveJS 的调试模式?

How to disable RactiveJS's debug mode when using RequireJS?

我知道用于禁用 RactiveJS 调试模式的压缩器片段。

Ractive.DEBUG = /unminified/.test(function(){/*unminified*/});

但是,如果我使用 RequireJS,我不确定在哪里添加它,因为 Ractive 不是全局的。我尝试使用 shim 配置并在回调函数中将 Ractive.DEBUG 更改为 false,但后来我 运行 使用 rv 插件时遇到问题,因为 RactiveJS 不应该与 shim 一起使用?

我能够使用构建文件中的以下内容解决它:

onBuildRead: function (moduleName, path, contents) {
    if (moduleName === 'ractive') {
        return contents.replace(
             'DEBUG: { writable: true, value: true }',
             'DEBUG: { writable: true, value: false }'
        );
    }
    return contents;
},

但是,这感觉很慢,因为它改变了原始文件。

我会把它放在你叫 new Ractive() 的地方的北边。抱歉,我不了解 RequireJS,所以我真的无法提出任何惯用的建议。