Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

所有的方法都挂载在 TRTC 上,如何做到 Tree Shaking ? #54

Closed
simo-an opened this issue Jul 3, 2023 · 3 comments
Closed

Comments

@simo-an
Copy link

simo-an commented Jul 3, 2023

比如我现在有一个会议的项目,在入会前的预览页只希望使用媒体相关的API,如 trtc.startLocalVideo ,现在 SDK 所有的方法都在 TRTC 上,我应该怎样做 Tree Shaking ?

@Rychou
Copy link
Contributor

Rychou commented Jul 3, 2023

你好,SDK 是经过混淆压缩的,没办法 Tree Shaking。

5.0 版本的 SDK 只保留了核心通话相关的 API,其他功能以插件形式提供,例如美颜、混音、AI 降噪。

@simo-an
Copy link
Author

simo-an commented Jul 4, 2023

Tree Shaking 和 代码是否混淆压缩应该没有关系吧?

如果不支持Tree Shaking的话,打出 ESM 的包意义何在?

@Rychou
Copy link
Contributor

Rychou commented Jul 11, 2023

Tree Shaking 和 代码是否混淆压缩应该没有关系吧?

如果不支持Tree Shaking的话,打出 ESM 的包意义何在?

你好,我理解您的需求是:业务侧没使用到的 API 不需要进行打包。

目前 SDK 是混淆压缩后,以单个主包 + n 个插件包的形式提供的,主包提供核心的音视频通话功能,不能再进一步 Tree Shaking 了。

ESM 包保留了 ES6 的语法,为了支持业务侧在 ESM 模块的项目中使用。
默认的 trtc.js 是 UMD 模块的,做了 ES6 转 ES5 的处理。

@Rychou Rychou closed this as completed Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants