-
initial package.json
npm init -y
-
安裝 react 套件
yarn add -D react react-dom typescript @types/react
-
.gitignore
node_modules.idea; dist; yarn - error.log;
-
tsconfig.json
{ "include": ["src"], "exclude": ["dist", "node_modules"], "compilerOptions": { "module": "esnext", "lib": ["dom", "esnext"], "importHelpers": true, "declaration": true, "sourceMap": true, "rootDir": "./src", "outDir": "dist", "strict": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, "noUnusedLocals": true, "noUnusedParameters": true, "moduleResolution": "node", "jsx": "react", "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true } }
-
package.json
{
"name": "react-counter-joeban0608",
"version": "1.0.0",
"description": "test npm react component",
"main": "dist/index.js",
"files": [
"dist"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"scripts": {
"clean": "rimraf dist",
"prebuild": "npm run clean",
"build": "tsc",
"preVersion": "npm run build",
"publish": "npm publish"
},
"repository": {
"type": "git",
"url": "https://github.com/joeban0608/npm-module-react-counter.git"
},
"keywords": [
"react",
"typescript"
],
"author": "joeban0608",
"license": "ISC",
"devDependencies": {
"@types/react": "^18.2.28",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.2.2"
},
"dependencies": {
"rimraf": "^5.0.5",
"sass": "^1.69.3"
}
}
-
publish
npm run preVersion npm run publish