Skip to content

core: Support multiple Webpack scripts#301

Draft
NotNite wants to merge 4 commits intomainfrom
notnite/multi-webpack
Draft

core: Support multiple Webpack scripts#301
NotNite wants to merge 4 commits intomainfrom
notnite/multi-webpack

Conversation

@NotNite
Copy link
Member

@NotNite NotNite commented Feb 7, 2026

Reopened from #294 because Cyn forgot to retarget it. Womp womp.

The primary motivation for this is loading libdiscoreWasmFetch along with web, as well as cleaning up Webpack patching code in general. We have to support multiple requires existing, so the main require in web gets marked with a special field. There's also multiple modules, some with conflicting IDs(!!!), so I'm not sure how that behaves. I do not know if patching modules in the other scripts works.

I haven't tested this very well, so feedback is appreciated! Browser support isn't done yet, and noTrack will also need to be updated for the libdiscore launch signature now that it's actually being evaluated. (We also may want to consider not patching this, as it's possible it might benefit us if Discord employees are intentionally flagging us anyways...)

Cyn reported that this was crashing her with her config, but it didn't work for me, so it's probably one of the extensions she had enabled that I don't have downloaded.

@NotNite NotNite self-assigned this Feb 7, 2026
@NotNite NotNite added enhancement New feature or request core This issue is related to moonlight's core labels Feb 7, 2026
@Cynosphere Cynosphere force-pushed the notnite/multi-webpack branch 3 times, most recently from 54ee7b4 to acd8f18 Compare March 20, 2026 22:08
NotNite and others added 3 commits March 20, 2026 16:16
The primary motivation for this is loading libdiscoreWasmFetch along
with web, as well as cleaning up Webpack patching code in general. We
have to support *multiple requires* existing, so the main require in
web gets marked with a special field. There's also multiple modules,
some with conflicting IDs(!!!), so I'm not sure how that behaves. I do
not know if patching modules in the other scripts works.

I haven't tested this very well, so feedback is appreciated! Browser
support isn't done yet, and noTrack will also need to be updated for
the libdiscore launch signature now that it's actually being evaluated.
Most of this was to work around extensions adding markdown while having
dependencies on React breaking with multi-webpack.

Remapped stub modules now insert modules *before* injected modules are
processed, meaning they should now inject on the same chunk as their
remapped dependencies are added in some cases.

Injected modules can now splice into chunks that are being currently
inserted. This reduces chunk count (like it matters) and should be a
slight speedup since a separate chunk doesn't need to be processed right
after.

The initial set of Webpack modules is now treated as a fake chunk and is
also has injected modules spliced into it. Entrypoint modules are
delayed slightly as they have to go into a new chunk to get required
properly.

(hopefully this is coherent enough rambling of how this works)
@Cynosphere Cynosphere force-pushed the notnite/multi-webpack branch 2 times, most recently from fc00a68 to 308ccb3 Compare March 21, 2026 01:38
I genuinely do not know any other better way to do this without forcing
extensions to load later (which means either forcing authors to rework
things or outright breaking what I fixed in an earlier commit; neither
are desireable).

This is still early enough in the load cycle that no HTTP requests are
made yet, so none of them are missing `launch_signature` in their super
properties.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core This issue is related to moonlight's core enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants