[POC] refactor: hide internal modules #4249
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
这个 PR 的意义是测试我们能否隐藏一些内部实现的模块,避免被用户所感知。
在实现二级入口的时候留下了一个问题:
重新导出二级入口的内容
在确保二级入口能够正确打包之后,我们还必须确保一级入口能够重新导出(re-export)所有二级入口的内容,以保持对旧的引入方式的兼容。方法是修改 ng-zorro-antd.module.ts 中对组件的导出方式:
然而 ng-packagr 的一个 bug 会造成导出同名变量的冲突。原因是,ngc 要求导出一个 module 下所有的 directive component service 和子 module,如果开发者没有在入口文件中显式的导出它们,ngc 就会隐式地导出,例如 date picker 组件的入口文件 ng-zorro-antd-date-picker.d.ts 里就有一些隐式导出的 component 和 module:
这在没有二级入口的情况下不会触发 bug,但是如果我们在一级入口重新导出,而且其他 module 也有这种隐式导出的话,就会发生导出重名变量的冲突。解决的办法是显式地导出这些变量。然而这带来了另外一个问题,即一些内部实现的东西也暴露给用户了。
比较合理解决方案是 ng-packagr 给 SEP 起一个有两级结构的 alias,比如 alias as θda 而不是 as θa。我们会在以后尝试修复掉这个瑕疵。
原文在这里。
这个 PR 旨在修复该瑕疵,向用户隐藏内部,特别是较为复杂组件的细节。
This pull request is to hide some implementation details from users, especially those of complicated components.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information