Skip to content

Commit 79ea263

Browse files
refactor: rewrite Module as an ES6 class (#4151)
This PR rewrites `module.js` to use a native ES6 `class` instead of `Class.extend()` - the same old inheritance helper that was removed from `node_helper.js` in #4147. The normal module API stays the same: modules still use `Module.register({...})`. Internally, `Module.create()` now creates a named subclass for each module, copies over a cloned definition, and only calls `init()` when it is actually a function. Outcome: one less file in the browser bundle, no more magic `_super()` wiring, better stack traces, and tests for the module creation path that did not exist before. `module.js` is also now a plain class with no external dependencies - an intentional step towards `export default Module` when browser scripts eventually move to native ES modules. Since these changes touch the core of how modules are created, I'd appreciate a close review and any feedback on edge cases I may have missed.
1 parent b38c7b7 commit 79ea263

7 files changed

Lines changed: 368 additions & 296 deletions

File tree

defaultmodules/newsfeed/newsfeed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Module.register("newsfeed", {
148148
}
149149
return Promise.resolve(wrapper);
150150
}
151-
return this._super();
151+
return Module.prototype.getDom.call(this);
152152
},
153153

154154
//Override fetching of template name

index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
<script type="text/javascript" src="js/logger.js"></script>
5151
<script type="text/javascript" src="translations/translations.js"></script>
5252
<script type="text/javascript" src="js/translator.js"></script>
53-
<script type="text/javascript" src="js/class.js"></script>
5453
<script type="text/javascript" src="config/basepath.js"></script>
5554
<script type="text/javascript" src="js/module.js"></script>
5655
<script type="text/javascript" src="js/loader.js"></script>

js/class.js

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)