3 ms·
Show HN: neo.mjs main thread addons
- tobiu 6y agoIn case you are not familiar with neo.mjs yet, it is a new UI framework which runs inside a web worker to use multi threading to the fullest. https://github.com/neomjs/neo https://github.com/neomjs/neo I just finished the main thread addons, so this is my highlight for the week. In case you want to work with other libraries or tools which need to include their own scripts, you can now do this with adding addons to the main thread. Examples are highlight js, showdown, Google Analytics. Each addon got an optional entry point: onDomContentLoaded, where you can import new scripts or stylesheets as needed. You can expose methods to other workers (in most cases to the app worker) to directly use them as promises. Choosing which addons you want to use is convenient: Just drop each one into the Neo.config (e.g. https://github.com/neomjs/neo/blob/dev/apps/realworld/index.html https://github.com/neomjs/neo/blob/dev/apps/realworld/index....) This way we can ensure, that the main-thread is as small as possible since each app only needs to include the addons it needs. Under the hood this is working with dynamic imports. This does work in the dev env with no JS builds at all (Chrome 80), as well as the webpack build versions (dist). Using webpack this was tricky at first, since the __webpack_public_path__ config is not sufficient: we only want to build one main thread for all possible apps, but app entry points can be on different folder tree levels. So, using publicPath for the main thread was not an option. A small override of __webpack_require__.p for the dist versions did already fix it though. Feedback appreciated!