# TypeScriptProjectTemplate **Repository Path**: developeros/type-script-project-template ## Basic Information - **Project Name**: TypeScriptProjectTemplate - **Description**: TypeScript project template - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2024-05-18 - **Last Updated**: 2025-01-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: typescript工程模版 ## README 使用rollup,以及相关官方插件 1. @rollup/plugin-typescript:打包typescript 2. rollup-plugin-dts:生成d.ts文件 ```shell # 下载模版 git clone git@gitee.com:developeros/type-script-project-template.git # 下载相关依赖 yarn # 执行ts代码 yarn tsx path/filename.ts # vitest yarn run test ``` ## 发布 创建组织,我的是@pkmer,组织名为pkmer [https://www.npmjs.com/org/create](https://www.npmjs.com/org/create) ```shell npm run publish:ci ``` ![success](./imgs/package.png) # 其他补充 ## `rollup.config.ts`配置 ```typescript import typescript from '@rollup/plugin-typescript'; import dts from 'rollup-plugin-dts' const config = [ { input: "src/index.ts", output: [ { file: "dist/index.mjs", format: "es", },{ file: "dist/index.cjs", format: "cjs", } ], plugins:[typescript()] }, { input: "src/index.ts", output: { file: "dist/index.d.ts", format: "es" }, plugins: [dts()] } ] export default config; ``` ## package.json ```json { "name": "@pkmer/core-lib", "version": "1.0.0", "license": "MIT", "type": "module", "main": "./index.cjs", "module": "./index.mjs", "types": "./index.d.ts", "packageManager": "yarn@1.22.22", "scripts": { "build": "tsx scripts/build.ts", "publish:ci": "tsx scripts/publish.ts", "test": "vitest run", "build:rollup": "rollup -c rollup.config.ts --configPlugin @rollup/plugin-typescript", "test:echo": "echo 'Hello World.Love TypeScript'" }, "devDependencies": { "@rollup/plugin-typescript": "^11.1.6", "@types/node": "^20.12.12", "rollup": "^4.17.2", "rollup-plugin-dts": "^6.1.0", "tslib": "^2.6.2", "tsx": "^4.10.3", "typescript": "^5.4.5", "vitest": "^1.6.0" }, "dependencies": { "@pkmer/core-lib": "^1.0.0" } } ```