I've published a TypeScript library onto NPM. On GitHub the dist (Link to Repository Folder) directory contains all the compiled JavaScript and d.ts files. However when running npm i <my_package> the result is a module with a dist folder only containing an index.js, the src folder is still present with the TypeScript files. The dist/src folder along with it's JavaScript and d.ts files are not found on the installed package consequently my module is not recognized or typed in Vanilla JavaScript projects.
Library tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": true,
"outDir": "./dist",
"strict": true,
},
"exclude": [
"node_modules/",
"dist/"
]
}
Library package.json
{
"name": "easy-trivia",
"version": "2.0.3",
"description": "A wrapper for the Open Trivia Database API. Built with TypeScript, works with VanillaJS.",
"keywords": [
"trivia",
"games",
"fun",
"api",
"easy",
"typescript",
"small",
"quiz",
"opentriviadatabase",
"opentdb",
"opentriviadb"
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"prettier": "npm run build && prettier -w src/",
"prepublish": "npm run prep",
"exec": "npm run build && node .",
"test": "npm run build && npx jest",
"prep": "npm run build && npm run test && npm run prettier"
},
"files": [
"src",
"typings"
],
"repository": {
"type": "git",
"url": "git+https://github.com/Elitezen/easy-trivia.git"
},
"author": "Elitezen",
"license": "ISC",
"bugs": {
"url": "https://github.com/Elitezen/easy-trivia/issues"
},
"homepage": "https://github.com/Elitezen/easy-trivia#readme",
"devDependencies": {
"@types/jest": "^27.0.3",
"@types/node": "^16.11.7",
"jest": "^27.5.1",
"nodemon": "^2.0.12",
"prettier": "2.4.1",
"ts-jest": "^27.1.3"
},
"engines": {
"node": ">=14.0.0",
"npm": ">=7.0.0"
}
}