如何使开发构建的行为与测试和生产相同?

How can I make Development builds behave the same as Testing and Production?

在开发应用程序时,我有 sencha app watch 运行。当然,这会监视文件更改并触发开发构建。所以现在我可以在浏览器中运行正在开发的应用程序。不错

问题是 sencha app build testing 的行为方式与开发版本不同。区别在于需要 requires。如果 requires 在 Development 中丢失,应用程序的功能就好像它在那里一样。

Chrome 发出警告 - 有时:

[W] [Ext.Loader] Synchronously loading 'MyApp.view.Etc'; consider adding Ext.require('MyApp.view.Etc') above Ext.onReady 

在测试构建之后(或类似地在生产构建之后),这些警告变成错误并且应用程序无法运行。

是的,在开发期间应确保添加所有 requires。但如果我错过了一个,我就有麻烦了——痛苦的 "but it works on my machine" 综合症。

如果我可以告诉 sencha app watch 不要原谅丢失 requires 或告诉 sencha app build testing(或 production)去做,这就不是问题了Development build 做了什么并推断出缺失的 requires.

如何使开发构建的行为与测试和生产相同?

你不能告诉 sencha app build production 来推断缺少的需求,因为 Sencha 只会发现一些必需的 类 在运行时丢失,当你的 JS 文件的源代码不应该在应用程序将开始搜索的路径。这是运行时错误,不是编译器错误。

所以你只能反过来做:你可以编辑 ExtJS 源代码。警告在 packages\core\src\class\ClassManager.js 中发出,如下所示:

Ext.log.warn("[Ext.Loader] Synchronously loading '" + name + "'; consider adding " +
                 "Ext.require('" + name + "') above Ext.onReady");

您可以将其更改为

Ext.raise("[Ext.Loader] Synchronously loading '" + name + "'; please add " +
                 "'" + name + "' to your requires list");