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

[UE] fix: compatible with bundlers. #1253

Conversation

PrimaryFantasty
Copy link
Contributor

Fixed #1252
大多数JS打包器为了ESM和CommonJS的兼容,引入了助手工具,在运行时判断"__esModule"的值,进而决定是否继续遍历获取模块的属性。"ue"和"cpp"模块中的loadType方法是延迟加载的思路,和这些助手函数有冲突,参考rollup/rollup#2954
引入"__esModule = true",可解决这个问题。在Windows下,UE5.0.3,打包工具为tsup的环境下,测试通过。不过,"__esModule"只是诸多打包器的惯用方式,并非语言官方规范中的属性。

@PrimaryFantasty PrimaryFantasty changed the title fix: compatible with bundlers. [UE] fix: compatible with bundlers. Mar 13, 2023
@chexiongsheng
Copy link
Collaborator

ue和cpp不是esm模块,__esModule不应该是true,__esModule设置为false能解决问题吗?

@PrimaryFantasty
Copy link
Contributor Author

ue和cpp不是esm模块,__esModule不应该是true,__esModule设置为false能解决问题吗?
确实不属于规范中的,感觉确实不用这样改了,或者最多做成可选配置的。改为false,不能解决这个问题,一些打包器是基于这个来判断是否interop的。不过,现在发现Rollup.js是有取消这个包装的选项的,在 https://rollupjs.org/configuration-options/ 中的API-ConfigurationOptions的 output.interop中,有看到自定义程度较高的配置选项,tsup的则没看到,这个问题更多归咎于这些打包器。车神,我把这个关掉吧,在issue或者文档上解释好就行了。

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

Successfully merging this pull request may close these issues.

[UE] Bug: Can not compatible with some JavaScript bundlers.
2 participants