我正在尝试使用downgradeModule策略在混合角度应用程序上实现HMR,但是它失败了。我来自另一个问题,Angular 5 / 1.x混合应用程序可以支持HMR吗?因为没有可接受的答案,我认为@scipper答案无法工作(下面的解释)。
我使用HMR(添加new webpack.HotModuleReplacementPlugin()
,添加的内容devServer.hot:true
和其他内容)设置了webpack配置(不是ng-cli,自定义配置),我可以看到它正在工作,我的输入文件正在重新加载,而没有用新的源重新加载整个页面,并且webpack应用了热更新很好,但是angular和angularjs应用程序无法正常工作(使用旧的缓存代码)。
我的计划是:
1)将模块hot accept添加到条目文件。
2)销毁angular.js应用程序(如果存在)(使用$ rootScope destroy?)。
3)销毁根angular.js应用节点(如果存在)。
4)使用类似的代码构建Angular模块
// bootstrap you new Angular 7 main module
const bootstrapFn = (extraProviders) => {
const platformRef = platformBrowserDynamic(extraProviders);
return platformRef.bootstrapModule(MyAngularSevenModule);
};
const downgradedModule = downgradeModule(bootstrapFn);
Run Code Online (Sandbox Code Playgroud)
5)调用或重新调用angularjs模块和依赖项+我的angular模块-这是我认为的主要问题。
6)引导angularjs应用程序(或$ compile + $ digest)。
已经尝试过:
- https://github.com/PatrickJS/angular-hmr -不会因为downgradeModule战略的工作(根节点是AJS)。
- https://github.com/vitaliy-bobrov/angular-hot-loader -很多,因为供应商和其他拦截器的错误都没有实现。
- https://github.com/noppa/ng-hot-reload
我以为引导程序会更新缓存的角度实体,但是在hmr重装角度之后,将使用旧的控制器/组件/指令(在“源”选项卡中使用新代码)。
有什么建议么?
我想ng test
在运行受影响的项目时将一些参数传递给命令(用于 CI 目的)。
例如:ng test --codeCoverage=true --watch=false --progress=false
。
怎么能通过nx affected:test
呢?
尝试过nx affected --help
,但它不包含此类信息。
作为一个简单的解决方案,我可以编写自定义节点脚本,执行并获取结果,nx print-affected
然后从此结果运行命令,但我想找到更有效的方法。
我的问题是否可以扩展架构属性?
我试过的:
collection.json
{
"$schema": "http://schema.angular.io/schematics/collection/2",
"name": "@my/schematics",
"description": "my default collection, containing all schematics that are used normally",
"schematics": {
"library": {
"extends": "@nrwl/angular:library", <--- extends nrwl library
"aliases": [ "lib" ],
"factory": "./library",
"description": "Create my library.",
"schema": "./library/schema.json"
}
}
Run Code Online (Sandbox Code Playgroud)
图书馆/schema.json
{
"$schema": "http://schema.angular.io/schematics/collection/2",
"id": "SchematicsAngularLibrary",
"title": "Create my library",
"type": "object",
"properties": {
"legacy": { <--- adds custom property
"type": "boolean",
"description": "Legacy mode",
"default": false
}
},
"required": []
}
Run Code Online (Sandbox Code Playgroud)
和我的简化原理图库/index.ts
import { chain, externalSchematic, …
Run Code Online (Sandbox Code Playgroud) angular ×3
angular-cli ×2
angularjs ×1
javascript ×1
monorepo ×1
nrwl ×1
nrwl-nx ×1
webpack-hmr ×1