To get started with this npm package template, follow these steps:
- To ensure that TypeScript automatically appends the
.js
extension, add the following line to yoursettings.json
file"typescript.preferences.importModuleSpecifierEnding": "js",
- Clone the repository to your local machine.
- Navigate to the project directory.
- In your
package.json
, use VSCode Find and Replace feature to change all instances of - Delete
docs
directory - Install the dependencies by running the following command:
npm install
- Remember to put your
d.ts
files in thesrc/types
directory
You can use the following command to run the Knip script:
npm run knip
- To add a new user to npm registry, run:
npm adduser
- To publish the package to the public npm registry, run:
npm publish --access public
- Target:
ESNext
- Uses the most recent ECMAScript version, allowing the use of latest features but may include unstable features - Module:
ESNext
- Adopts the latest module system, which supports modern tooling but may not be compatible with older environments - OutDir:
./dist
- Directs compiled files to a specific directory, keeping source files clean but requires directory management - RootDir:
./src
- Specifies the root folder for source files, organizing code effectively but necessitating correct path settings - ModuleResolution:
Bundler
- Delegates resolution logic to a bundler, simplifying module handling while increasing dependency on external tools - esModuleInterop:
true
- Facilitates importing CommonJS modules into ES modules, increasing compatibility but potentially obscuring module differences - ForceConsistentCasingInFileNames:
true
- Prevents casing issues in module imports, enhancing portability but requiring consistent file naming - Strict:
true
- Enforces strict typing, improving code reliability but increasing complexity in type management - SkipLibCheck:
true
- Skips checking of declaration files to speed up compilation, though may miss type errors in library definitions - ResolveJsonModule:
true
- Allows importing JSON files directly into TypeScript files, increasing ease of use but adding more steps to the build process - SourceMap:
true
- Generates source map files for debugging, improving developer experience but slightly increasing output size - Declaration:
true
- Generates type declaration files automatically, beneficial for library authors but adds to the compilation time - Incremental:
true
- Reduces build times by using incremental compilation, enhancing performance but may lead to incomplete recompiles if not managed correctly - StrictNullChecks:
true
- Forces explicit handling ofnull
andundefined
, increasing type safety but requiring more thorough initialization checks - Include:
src/**/*.ts
- Ensures all relevant files are included, simplifying project setup but requiring correct glob patterns - Exclude:
node_modules
,**/*.spec.ts
- Prevents unnecessary files from being compiled, reducing clutter but requiring explicit exclusion patterns