如何使开发版本的行为与测试和生产相同? [英] How can I make Development builds behave the same as Testing and Production?

查看:62
本文介绍了如何使开发版本的行为与测试和生产相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开发应用程序时,我正在运行 sencha app watch .当然,这会监视文件更改并触发开发构建.因此,现在我可以在浏览器中锻炼正在开发的应用程序了.很好.

When developing an app I have sencha app watch running. This, of course, watches for file changes and triggers a development build. So now I can exercise the app under development in the browser. Nice.

问题是 sencha应用程序构建测试的行为与开发版本不同.区别在于需要 requires .如果开发中缺少 requires ,则该应用程序会像在那儿一样运行.

The problem is a sencha app build testing does not behave the same way as the Development build. The difference is in needing requires. If a requires is missing in Development, the app functions as if it was there.

Chrome发出警告-有时:

Chrome throws a warning - sometimes:

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

在经过测试构建之后(或类似地在生产构建之后),这些警告变为错误,并且该应用无法运行.

After a Testing build (or similarly after a Production build), those warnings become errors and the app does not function.

是的,在开发期间,应确保添加了所有 requires .但是,如果我想念一个,那我就麻烦了-痛苦的但它可以在我的机器上工作"综合症.

Yes, during development time one should ensure all requires are added. But if I miss one I'm in trouble - the painful "but it works on my machine" syndrome.

如果我可以告诉 sencha应用监视不容忍丢失的 requires 或告诉 sencha应用构建测试,这将不是问题.code>(或 production )执行开发版本的工作并推断出丢失的 requires .

This would not be a problem if either I could tell sencha app watch to not be forgiving of missing requires or to tell sencha app build testing (or production) to do what the Development build does and infer the missing requires.

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

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

推荐答案

您无法告诉 sencha应用生成量来推断缺少的需求,因为Sencha仅在运行时发现某些必需的类缺失.,当JS文件的源代码在应用程序开始搜索的路径上不可用时.这是运行时错误,而不是编译器错误.

You cannot tell sencha app build production to infer the missing requires, because Sencha only finds out that some required classes are missing AT RUNTIME, when the source code of your JS files should not be available at the path that the application would start searching. It's a runtime error, not a compiler error.

因此,您只能采取另一种方法:您可以编辑ExtJS源代码.像这样在 packages \ core \ src \ class \ ClassManager.js 中发出警告:

So you can only do it the other way around: you can edit the ExtJS source code. The warning is raised in packages\core\src\class\ClassManager.js like this:

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");

这篇关于如何使开发版本的行为与测试和生产相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆