{"id":20625096,"url":"https://github.com/jasonsturges/typescript-npm-package","last_synced_at":"2025-04-15T15:05:01.492Z","repository":{"id":142401733,"uuid":"367415547","full_name":"jasonsturges/typescript-npm-package","owner":"jasonsturges","description":"TypeScript library npm package template","archived":false,"fork":false,"pushed_at":"2022-12-10T20:57:59.000Z","size":198,"stargazers_count":24,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T15:04:53.121Z","etag":null,"topics":["boilerplate","library","npm","package","rollup","template","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jasonsturges.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-14T16:07:52.000Z","updated_at":"2024-11-17T14:59:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"734c7ad4-459d-4642-8e67-1b7dc5db7d01","html_url":"https://github.com/jasonsturges/typescript-npm-package","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonsturges%2Ftypescript-npm-package","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonsturges%2Ftypescript-npm-package/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonsturges%2Ftypescript-npm-package/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonsturges%2Ftypescript-npm-package/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jasonsturges","download_url":"https://codeload.github.com/jasonsturges/typescript-npm-package/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249094932,"owners_count":21211837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boilerplate","library","npm","package","rollup","template","typescript"],"created_at":"2024-11-16T13:08:07.806Z","updated_at":"2025-04-15T15:05:01.484Z","avatar_url":"https://github.com/jasonsturges.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TypeScript NPM Package\nScaffold TypeScript npm packages using this template to bootstrap your next library.\n\nThis project includes:\n- [TypeScript](https://www.typescriptlang.org/)\n- [Rollup](https://rollupjs.org/)\n- [Microsoft API Extractor](https://api-extractor.com/)\n- [TypeDoc](https://typedoc.org/)\n\nVersions of this template:\n- [Vite TypeScript library npm package](https://github.com/jasonsturges/vite-typescript-npm-package)\n- [Vite JavaScript library npm package](https://github.com/jasonsturges/vite-npm-package)\n- [Rollup JavaScript library npm package](https://github.com/jasonsturges/npm-package-boilerplate)\n- [Rollup TypeScript library npm package](https://github.com/jasonsturges/typescript-npm-package)\n\n\n## Getting Started\n\nBegin via any of the following:\n\n- Press the \"*Use this template*\" button\n\n- Use [degit](https://github.com/Rich-Harris/degit) to execute: \n\n    ```\n    degit github:jasonsturges/typescript-npm-package\n    ```\n    \n- Use [GitHub CLI](https://cli.github.com/) to execute: \n\n    ```\n    gh repo create \u003cname\u003e --template=\"https://github.com/jasonsturges/typescript-npm-package\"\n    ```\n    \n- Simply `git clone`, delete the existing .git folder, and then:\n\n    ```\n    git init\n    git add -A\n    git commit -m \"Initial commit\"\n    ````\n\nRemember to use `npm search \u003cterm\u003e` to avoid naming conflicts in the NPM Registery for your new package name.\n\n\n## Usage\n\nThe following tasks are available for `npm run`:\n\n- `dev`: Run Rollup in watch mode to detect changes to files during development\n- `build`: Run Rollup to build a production release distributable\n- `build:types`: Run Microsoft API Extractor to rollup a types declaration (`d.ts`) file \n- `docs`: Run TypeDoc for TSDoc generated documentation in the \"*docs/*\" folder\n- `clean`: Remove all build artifacts\n\n\n## Development\n\nWhile test driven development (TDD) would be a good approach to develop your library, also consider creating an app for prototyping and local testing of your library.\n\nTo test within the library, consider using [Storybook](https://storybook.js.org/).  This approach runs a `storybook` script to load local source files for development.\n\nOtherwise, follow these steps to test the package from another project:\n\n**From your library project**, issue the `npm link` (or `yarn link`) command:\n\n```\nnpm link\n```\n\nStart Rollup in watch mode:\n\n```\nnpm run dev\n```\n\n**Create a test app project**, by doing the following:\n\nTo use your npm package library locally for development, create a new project in a separate folder:\n\n```\nmkdir test-app \u0026\u0026 cd test-app\nnpm init\n```\n\nTake the defaults from `npm init`; then, add TypeScript:\n\n```\nnpm install typescript --save-dev\n```\n\nIn the package.json of your test app, add the following two things:\n- Set the `type` of your package to `module`\n- Add a `start` script to execute your app\n\n```json\n\"type\": \"module\",\n\"scripts\": {\n  \"start\": \"tsc \u0026\u0026 node index.js\",\n},\n```\n\nLink to your library using the `npm link \u003cname\u003e` (or `yarn link \u003cname\u003e`) command - be sure the `\u003cname\u003e` matches your library's package.json name.  For example:\n\n```\nnpm link typescript-npm-package\n```\n\nAdd a \"*tsconfig.json*\" file to your test app that includes a `baseUrl` and references the `paths` to your npm linked module.  Again, be sure the `paths` name matches your library's package.json name.  For example:\n\n```json\n{\n  \"compilerOptions\": {\n    \"target\": \"es6\",\n    \"module\": \"esnext\",\n    \"moduleResolution\": \"node\",\n    \"strict\": true,\n    \"esModuleInterop\": true,\n    \"baseUrl\": \".\",\n    \"paths\": {\n      \"typescript-npm-package\": [\"node_modules/typescript-npm-package/src\"],\n      \"typescript-npm-package/*\": [\"node_modules/typescript-npm-package/src/*\"]\n    }\n  }\n}\n```\n\nNow, run your app via `npm start`.\n\nAs an example, if your library's \"*index.ts*\" file contained:\n\n```ts\nexport const sayHi = () =\u003e {\n  console.log(\"Hi\");\n};\n```\n\n...your test app would implement an import using your package name, such as:\n\n```ts\nimport { sayHi } from \"typescript-npm-package\";\n\nsayHi();\n```\n\n\n## Development Cleanup\n\nOnce development completes, `unlink` both your library and test app projects.\n\n**From your test app project**, unlink the library using `npm unlink \u003cname\u003e` (or `yarn unlink \u003cname\u003e`) command:\n\n```\nnpm unlink typescript-npm-package\n```\n\n**From your library project**, issue the `npm unlink` (or `yarn unlink`) command:\n\n```\nnpm unlink\n```\n\n\n## Release Publishing\n\nUpdate your `package.json` to next version number, and remember to tag a release.\n\nOnce ready to submit your package to the NPM Registry, execute the following tasks via `npm` (or `yarn`):\n\n- `npm run clean` \u0026mdash; Assure a clean build\n- `npm run build` \u0026mdash; Build the package\n- `npm run build:types` \u0026mdash; Build API Extractor d.ts declaration\n\nAssure the proper npm login:\n\n```\nnpm login\n```\n\nSubmit your package to the registry:\n\n```\nnpm publish --access public\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonsturges%2Ftypescript-npm-package","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjasonsturges%2Ftypescript-npm-package","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonsturges%2Ftypescript-npm-package/lists"}