8 Hobbies Technology

Dedicated to open source and web technology

Maintaining an Open Source JavaScript Project? Help Dependents Retain Notices

This post is not legal advice. By reading this post, you agree and acknowledge that this post does not advise you on how to properly license your work and you would not rely on this post to license your work; that this post does not advise licensees of open source work on how to comply with the licenses; and that this post only provides technical guidance on programming tasks that are common to licensing open source projects. Most popular open source licenses require redistributors to retain the copyright and permission notices, among other things. For example, even the brief MIT License explicitly requires so: …The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software… However, without any automation, this simple task is not so simple for a browser JavaScript project: Tens and even hundreds of open source dependencies are often bundled and minified into a single .js file. Then, this .js file is commonly distributed to browsers via the Internet. As maintainers of open source JavaScript projects, what can we do to make retaining copyright and permission notices easier for dependent browser JavaScript projects? ...

April 20, 2024 · (updated April 21, 2024) · 3 min · 573 words · 8 Hobbies

Unleash Git Power with User Configuration

Git is an open source distributed version control system. It is currently the most popular version control system according to various surveys, and has been the core driver of many popular development platforms, such as GitHub, GitLab, Bitbucket, etc. While Git comes with a decent default configuration, it is far from the full power of Git. In this post, we will walk through some Git user configuration that unleash more power within Git. ...

April 11, 2024 · (updated April 27, 2024) · 4 min · 711 words · 8 Hobbies

Make TypeDoc Generate a 404 Page

Motivation TypeDoc is a document generator that, among other things, converts comments in TypeScript source code into rendered HTML documentation. The generated HTML documentation can be hosted on static website hosting services, such as GitHub Pages, GitLab Pages, Netlify, and CloudFlare Pages. All of them by default use a 404.html file as the content of the 404 page of the site. However, TypeDoc does not generate a 404.html by default. How can we make TypeDoc generate such a 404.html file? ...

April 6, 2024 · (updated April 20, 2024) · 3 min · 464 words · 8 Hobbies

Typing Wrapper Functions in Typescript

Motivation Very often in TypeScript, we would like to wrap an existing function into a wrapper function, with some additional preprocessing or postprocessing. For example, function existingFunc(arg1: number, arg2: string): number { return arg1 + arg2.length; } function wrapperFunc(arg1: number, arg2: string): number { // Preprocess arg1 and arg2... return existingFunc(arg1, arg2); } In this case, the wrapper function often shares the same parameter types and return type. If the existing function is already typed, we can reuse those typing information. This would reduce redundancy and is also able to reflect any changes that would happen in the typing of the existing function in the future. ...

April 3, 2024 · (updated April 27, 2024) · 3 min · 543 words · 8 Hobbies

Test the Presence of a Material UI Icon in Jest/Vitest

Testing the presence of a Material UI Icon in Jest/Vitest can be done by using the Testing Library. First, in the production code, assign a titleAccess attribute to the icon. For example, if the icon of interest is AddIcon, the code would look like: <AddIcon titleAccess="My Add Icon" /> This attribute would also surface to the user interface. ...

April 2, 2024 · (updated April 20, 2024) · 1 min · 197 words · 8 Hobbies