自定义npm包leon-theme发布后dist文件缺失,无法导入React项目
问题:npm包发布后dist文件缺失,导致React项目导入失败
我开发了leon-theme这个npm包,本地执行npm run build后,dist文件夹构建完全正常,但发布到npm之后,包里除了README和package.json之外,所有构建产物都不见了。在全新的React项目中导入该包时,直接提示找不到模块。
以下是相关配置:
tsconfig配置
{ "compilerOptions": { "module": "ES6", "target": "es2016", "lib": ["ES2020", "DOM"], "jsx": "react", "declaration": true, "declarationDir": "types", "sourceMap": true, "allowSyntheticDefaultImports": true, "noEmit": false, "outDir": "./dist/lib/es6", "moduleResolution": "node" }, "include": ["src/**/*"] }
根目录package.json
{ "name": "leon-theme", "version": "1.0.0", "module": "lib/es6/index.js", "description": "A simple React style & component library", "scripts": { "build": "rm -rf dist/lib && tsc --build" }, "author": "Leon Gaban", "license": "ISC", "dependencies": { "react": "^18.2.0" }, "devDependencies": { "@types/react": "^18.2.22", "jest-environment-jsdom": "^29.7.0", "tslib": "^2.6.2", "typescript": "^5.2.2" }, "files": [ "dist" ], "types": "dist/index/.d.ts" }
dist目录下的package.json
{ "name": "leon-theme", "version": "0.0.6", "module": "lib/es6/index.js", "description": "A simple React style & component library", "homepage": "https://github.com/leongaban/leon-theme", "bugs": { "url": "https://github.com/leongaban/leon-theme/issues" }, "repository": { "type": "git", "url": "git+https://github.com/leongaban/leon-theme.git" }, "keywords": [ "javascript", "theme", "buttons", "leon" ], "scripts": { "build": "rm -rf dist/lib && tsc --build" }, "author": "Leon Gaban", "license": "ISC", "dependencies": { "react": "^18.2.0" }, "devDependencies": { "@types/react": "^18.2.22", "jest-environment-jsdom": "^29.7.0", "tslib": "^2.6.2", "typescript": "^5.2.2" }, "files": [ "dist" ], "types": "dist/index/.d.ts" }
相关截图
内容的提问来源于stack exchange,提问作者Leon Gaban
相关产品推荐
相关产品推荐

