user4092086
user4092086

Reputation: 1226

Publishing typescript package without ts files?

I have a typescript project that I want to publish it, I generate all the js files in a directory called build and all declaration files in a directory called declaration, I don't want to include .ts files in my published version I was wonder how can I do this without using gulp?

here is my tsconfig.json

{
    "compilerOptions": {
       "target": "es6",
        "lib": ["es6", "dom"],
        "types": ["reflect-metadata"],
        "module": "commonjs",
        "moduleResolution": "node",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "outDir": "build",
        "declarationDir": "declaration"
    },
    "exclude": [
        "node_modules"
    ]
}

and my package.json:

{
  "name": "data-layer",
  "version": "1.1.4",
  "description": "data access layer",
  "main": "./build/index.js",
  "types": "./declaration/index.d.ts",
...

Upvotes: 2

Views: 736

Answers (1)

smnbbrv
smnbbrv

Reputation: 24581

Just use .npmignore file where you tell to ignore all files that are .ts but not .d.ts

*.ts
!*.d.ts

More information on npmignore you can find here

Upvotes: 2

Related Questions