/ts-lib-skel

TypeScript library skeleton project

ts-lib-skel

Typescript library skeleton project.

Create Yarn Project

1. Yarn(Classic v1) Init

Initialize 'Yarn' in the project directory.

> mkdir ts-lib-skel
> cd ts-lib-skel
> yarn init

question name: {project-name} Enter
question version: 0.1.0 Enter
question description: {description} Enter
question entry point: dist/index.js Enter
question repository url: Enter
question author: {name} <{email}> Enter
question license: Enter
question private: {Y/N} Enter

2. Add .gitignore

Create .gitignore file.

> touch .gitignore

Open the .gitignore file and add the following contents.

node_modules/
dist/

3. Add .npmignore

Create .npmignore file.

> touch .npmignore

Open the .npmignore file and add the following contents.

**/.*
lib/
node_modules/


Upgrade to Yarn Berry

1. Upgrade 'Yarn' version

  • Upgrade 'Yarn' version to latest stable version.
  • When running on Windows, antivirus real-time monitoring must be turned off and run.
> yarn set version stable
> yarn install

2. Add .gitattributes

Create .gitattributes file.

> touch .gitattributes

Open the .gitattributes file and add the following contents.

.yarn/releases/** binary
.yarn/plugins/** binary

3. Update .gitignore

Open the .gitignore file and add the following contents.

.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

4. Update .yarnrc.yml

Open the .yarnrc.yml file and add the following content.

nodeLinker: node-modules


Enabling Yarn Zero-Installs

1. Update .yarnrc.yml

Open the .yarnrc.yml file and delete the following content.

nodeLinker: node-modules

2. Update .gitignore

2-1. Open the .gitignore file.

2-2. Delete the following content.

.pnp.*

2-3. Add the following content.

!.yarn/cache

3. Update .gitattributes

Open the .gitattributes file and add the following content.

.yarn/cache/** binary

4. Yarn install

> yarn install