Skip to content

[UE] Bug: UE版本的js环境中没有puer:开头的初始化env行为,导致一些使用esm的模块无法正常使用 #2248

@breaking153

Description

@breaking153

前置阅读 | Pre-reading

Puer的版本 | Puer Version

2.2.3

UE的版本 | UE Version

5.7

发生在哪个平台 | Platform

win

错误信息 | Error Message

一些esm模块会使用import.meta.url的esm模块参数,在UE插件中使用会报错,经过查看源码发现puerts在unity中存在初始化环境变量代码:unity/native/papi-v8/source/BackendEnv.cpp
UE是否能够添加类似代码以支持相关esm模块?

问题重现 | Bug reproduce

例子模块:ps-list

Image

报错信息:
Error Puerts (0x00000210AE6AB0B0) TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of URL. Received undefined
Error Puerts TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of URL. Received undefined
Error Puerts at new NodeError (node:internal/errors:372:5)
Error Puerts at fileURLToPath (node:internal/url:1420:11)
Error Puerts at ../../../../../../G-GameProject/UE/CombatVarProject/node_modules/ps-list/index.js:8:32
Error Puerts at executeModule (D:\G-GameProject\UE\CombatVarProject\Content\JavaScript\puerts\modular.js:63:23)
Error Puerts at require (D:\G-GameProject\UE\CombatVarProject\Content\JavaScript\puerts\modular.js:183:29)
Error Puerts at require (D:\G-GameProject\UE\CombatVarProject\Content\JavaScript\puerts\modular.js:176:33)
Error Puerts at D:\G-GameProject\UE\CombatVarProject\Content\JavaScript\Init.js:3:11
Error Puerts at executeModule (D:\G-GameProject\UE\CombatVarProject\Content\JavaScript\puerts\modular.js:70:9)
Error Puerts at require (D:\G-GameProject\UE\CombatVarProject\Content\JavaScript\puerts\modular.js:183:29)

Metadata

Metadata

Assignees

Labels

UnrealbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions