typescript-library-starter
raw JSON → 0.0.1 verified Sat Apr 25 auth: no javascript maintenance
A starter project for creating TypeScript libraries with zero setup. It provides RollupJS for optimized bundles, Jest for testing and coverage, Prettier and TSLint for code formatting, TypeDoc for automatic documentation, and optional semantic release with changelog generation. Version 0.0.1 is an early release; the package is not actively maintained and is intended as a template generator rather than a runtime library. It competes with other starters like create-react-library and tsdx, but is more opinionated.
Common errors
error Cannot find module 'printnode-ts' ↓
cause The package 'printnode-ts' is not published on npm; it's a placeholder from the starter.
fix
Use the starter template to create your own library; do not npm install 'printnode-ts'.
error Error: TSLint is not installed ↓
cause The starter expects TSLint as a devDependency but may not be installed if you skipped npm install.
fix
Run npm install from the cloned repository root.
error TypeError: Cannot destructure property 'default' of ... ↓
cause Using `const { default } = require('mylib')` when the CommonJS module exports as default directly.
fix
Use
const myLib = require('mylib') instead. Warnings
gotcha This is a starter template, not a published library. The npm package 'printnode-ts' is likely a placeholder; the actual code from the README clones a repository, not installs from npm. ↓
fix Do not install 'printnode-ts' from npm expecting a usable library. Instead, use the template to scaffold your own library.
deprecated TSLint is deprecated in favor of ESLint. The starter uses TSLint which may cause compatibility issues with modern TypeScript. ↓
fix Migrate to ESLint with typescript-eslint plugin.
gotcha The 'engines' field in package.json specifies Node >=6.0.0, but contemporary TypeScript and Rollup plugins may require Node 10+. ↓
fix Update engines to Node >=12 or use an older version of dependencies.
gotcha Greenkeeper badge is outdated; the service has been rebranded to Greenkeeper (later acquired) and may not work. ↓
fix Remove Greenkeeper badge or replace with Renovate or Dependabot configuration.
Install
npm install printnode-ts yarn add printnode-ts pnpm add printnode-ts Imports
- default
import myLib from 'printnode-ts' - something
import something from 'printnode-ts/dist/lib/something' - require wrong
const { default } = require('printnode-ts')correctconst myLib = require('printnode-ts')
Quickstart
// Clone the repository and set up your library name
git clone https://github.com/alexjoverm/typescript-library-starter.git my-library
cd my-library
npm install
// After setup, edit src/index.ts to export your API
export function greet(name: string): string {
return `Hello, ${name}!`;
}
// Build the library
npm run build
// Test it
import { greet } from './dist';
console.log(greet('World')); // Hello, World!