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] Bug: Can not compatible with some JavaScript bundlers. #1252

Closed
3 tasks done
PrimaryFantasty opened this issue Mar 13, 2023 · 3 comments
Closed
3 tasks done

[UE] Bug: Can not compatible with some JavaScript bundlers. #1252

PrimaryFantasty opened this issue Mar 13, 2023 · 3 comments
Assignees
Labels
bug Something isn't working Unreal

Comments

@PrimaryFantasty
Copy link
Contributor

前置阅读 | Pre-reading

Puer的版本 | Puer Version

All

UE的版本 | UE Version

All

发生在哪个平台 | Platform

All

错误信息 | Error Message

"ue"等ts模块中的类型无法找到.

问题重现 | Bug reproduce

使用一些常见的JS构建工具,例如Rollup.js,tsup等,bundle代码后运行,日志中即可看到报错信息。

@chexiongsheng
Copy link
Collaborator

webpack可以声明ue是外部模块,相信其它构建工具也会有类似的设置。

@PrimaryFantasty
Copy link
Contributor Author

webpack可以声明ue是外部模块,相信其它构建工具也会有类似的设置。

确实可以声明是外部模块的,但是它们一般会作类似这样的操作:
dynamic import interop in rollup.js
在tsup中,确实也声明了外部模块,转换后的代码是commonjs的。比如,我把"ue"设置为外部模块后,它会转成直接调用require函数的代码:
image
目前我的方式是遵循这些打包器的习惯,设置了__esModule为true。

@PrimaryFantasty
Copy link
Contributor Author

解决方案可参考 #1253
或者,当构建工具没有良好的配置选项时,参考本issue的思路也能避开这个问题,但做法并不符合ECMA规范。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Unreal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants