Skip to content

4nduril/library-starter

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 

This is example code for the article series

Publish a modern JavaScript (or TypeScript) library

Read it here.

The code itself does not much: It exports a React component (ExampleComponent) that uses a custom hook which returns the props that have changed before the last re-render. The hook is also exported separately (usePropsThatChanged). It returns a Set. An array would work the same way but we use a Set for illustrating transpiling/polyfilling of ES2015+ features.

Variants

Throughout the article series I present common alternatives to solve the same task. For instance, transpiling modern code to incapable targets with Babel or with the TypeScript compiler. I decided to show all of these variants here in this repository by utilizing branches. The master branch will reflect my personal choices while other, aptly named branches will show configurations for other combinations of tools.

The following table will list them.

tool / feature master typescript typescript-tsc node-esm
Transpiling with Babel x x x
TypeScript x x
Transpiling with tsc x
Signal NodeJS ESM - - - x