Issue
Overview
I have a helper function library that I want to import into my projects.
Question
How can I correctly configure my tsconfig.json so only the files necessary are required when using npm run build? I don't want any extra files in to be included.
tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"module": "CommonJS",
"declaration": true,
"checkJs": true,
"sourceMap": true,
"outDir": "./dist",
"removeComments": true,
"strict": true,
"noImplicitAny": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"skipLibCheck": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
},
"include": ["src/**/*"],
"compileOnSave": false,
"buildOnSave": false
}
Included in package.json
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
What's showing in node_modules when imported into a project
- Should
srcbe showing?? - How can I remove
jest.config.js?
Solution
The tsconfig.json file doesn't have anything to do with what ends up in the final npm package. Per default (more or less) everything that is contained in your project directory will also be added into your package (except the node_modules folder).
There are two ways to control the contents of your package
Create a file named
.npmignoreand add every file/folder you want to be excluded from your package. This works similar to the.gitignorefile. See the docs for details.You can add a
filesarray to yourpackage.jsonand add all files/folders you want to be included in your package. See docs for details.
What files need to be in your package, depends on the functionality your package provides. The test configuration probably isn't required for the final package, neither is the source ...
Answered By - derpirscher

0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.