armory3d / armory3d/armory

[HTML5] Uncaught ReferenceError: require is not defined

Open
#3,090 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
3.3k
Forks
353
Avg merge
3d 16h
Merged PRs (30d)
1

Description

Due to security-related changes of newer electron versions used by Kha for the html5 target, `require()` is no longer available by default. This will lead to errors in `Assets.html5WriteFile()` as well as `zui.Ext.fileBrowser()` when running Armory2D from within VSCode.

I don't know a good way around this. Robert mentioned on the Kha discord (see [this](https://discord.com/channels/757530409876717609/757530769315856425/836349945497518182)) that you can make `require()` available again by exposing it in Kha's `preload.js`, however that would require a change in Kha or every user would have to do that themselves. There also seems to be a way to turn off this security measure, but I couldn't find out how.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing Assets.html5WriteFile() and zui.Ext.fileBrowser() in the HTML5 target, then inspect Kha's preload.js and the Electron security changes mentioned in the issue. Verify how Armory2D runs from VSCode and whether the affected paths still raise “require is not defined.” Done means both operations work without that error, with any required Kha-side dependency identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.