I've recently developed a Typescript Package and I want to test it in an application before publishing it on NPM.
The main file (index.ts) of the package is structured like this =>
import Builder from './core/builder';
export default Builder;
Essentially, there are multiple files within the package, but I aim for the user to utilize a "static" class Builder
that I export in the index. Therefore, the user can simply import it as import Builder from 'builderts'
The structure of my package.json
looks like this:
"name": "builderts",
"main": "./dist/builderts.js",
"types": "./dist/builderts.d.ts",
"files": [
"dist/*"
],
"scripts": {
"preversion" : "npm run lint",
"prepare": "npm run build",
"prepublishOnly": "npm test && npm run lint",
"version" : "npm run format && git add -A src",
"postversion" : "git push && git push --tags",
"build": "tsc",
"watch": "tsc-watch",
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
"lint": "eslint tsconfig.json"
},
As for my tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "amd",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outFile":"./dist/builderts.js",
"outDir": "dist",
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
The issue I'm encountering is when I tried to create a small testing project and installed the module using
npm install absolute/path
the installation was successful, but upon trying to import the package with
import Builder from 'builderts';
I realized I didn't have autocomplete, and received an error message stating
File 'D:/User/Local/gitRepo/builderts/dist/builderts.d.ts' is not a module.
I'm puzzled about what might be missing in the process.