Repository navigation
Conversation
|
[Commented by Copilot on behalf of @bghgary] Closing while we reconsider the API. This proposal mixes host script loading with a Web Worker-specific compatibility shim without defining how dynamic imports should work across the supported engines. |
Expose _native.loadScript with a host resolver for immediate or asynchronous script resources, without a file or network fallback. Document a Webpack 5 configuration that waits for both chunk registration and host evaluation using Webpack's existing import promises. Create deferred promises only for rejected loader calls to avoid retaining unused promises during runtime shutdown. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
08b5254 to
f22548e
Compare
|
[Commented by Copilot on behalf of @bghgary] Reopening with the host-controlled script loader and a documented Webpack 5 example. The worker-specific |
There was a problem hiding this comment.
🟡 Changes recommended
The new tests are omitted from Android’s separately maintained UnitTestsJNI target.
1 open finding
What changed in this PR
Adds an optional host-controlled loader for evaluating bundled JavaScript resources without filesystem or network access.
Changes:
- Adds
_native.loadScriptwith synchronous and asynchronous resolvers. - Adds validation, error handling, tests, and CMake integration.
- Documents host usage and Webpack 5 chunk loading.
| File | Description |
|---|---|
CMakeLists.txt |
Adds the plugin option and directory. |
Plugins/CMakeLists.txt |
Conditionally enables the plugin. |
Plugins/DynamicScriptLoader/CMakeLists.txt |
Defines the plugin library. |
Plugins/DynamicScriptLoader/Include/Babylon/Plugins/DynamicScriptLoader.h |
Declares the resolver API. |
Plugins/DynamicScriptLoader/Source/DynamicScriptLoader.cpp |
Implements script resolution and evaluation. |
Plugins/DynamicScriptLoader/README.md |
Documents usage and Webpack integration. |
Tests/UnitTests/CMakeLists.txt |
Registers desktop tests. |
Tests/UnitTests/Source/Tests.DynamicScriptLoader.cpp |
Tests loading, validation, and errors. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Use the supported named-property check to preserve an existing loadScript entry. HasOwnProperty misses duplicates on JavaScriptCore and is unimplemented on JSI. Include the loader tests and conditional library dependency in Android's separately executed UnitTestsJNI target. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

[Created by Copilot on behalf of @bghgary]
Context
Hosts that package JavaScript as resources need to load deferred bundles without enabling unrestricted file or network access. Resource delivery may be immediate or asynchronous.
Compatibility
The runtime API evaluates classic scripts and is independent of the bundler; it does not add native ECMAScript module loading. Source-level
import()must be transformed by the bundler. SeePlugins/DynamicScriptLoader/README.mdfor host integration and a Webpack 5 configuration example.Browser builds keep their normal chunk transport. The Webpack example is for packaged JavaScript chunks, not a development server or hot module replacement.