Preserve the module insertion order in forEachModuleOfType
#9305
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a bugfix for #9289.
Since the insertion order is maintained in $tw.modules.titles, this object is used as source tiddler list.The culprit is not the maintenance of object insertion order (which is preserved in modern JS), but the module definition order. Tiddler modules are currently defined before shadow modules and so appear first during module registration, i.e. subsequent shadow modules will overwrite any tiddler modules with the same exports.
Each group is sorted alphabetically, so plugin shadows currently overwrite core shadows (assuming their name starts with $:/plugins/). The problem is just with tiddlers not overwriting shadows.
The solution proposed here is to swap the order of $tw.wiki.defineTiddlerModules() and $tw.wiki.defineShadowModules() in boot.js, so that tiddlers are defined later.