teambit / envs

Component development environments for the Bit community
https://bit.dev/bit/envs
Other
64 stars 9 forks source link

Imported component source files are compiled again by tsc when importing #51

Closed olivr70 closed 4 years ago

olivr70 commented 5 years ago

Describe the bug

When importing a component written in Typescript, compiling the importing project compiles .ts files of the component, instead of using dist/.js and dist/.d.ts files

Steps to Reproduce

Hello,

I am just starting with bit.dev. I have been using Typescript for years.

I have made 2 private small components : @bit/olivr70.permnat.session@0.0.4 and @bit/olivr70.permnat.textcleaning@1.0.0 (I cannot make them public, but it is ok for support to look at them)

They are structured in the same way : 'index.ts' exports some symbols from other .ts files, .js and .map files in a ./dist folder. "bit test" runs ok with a few jest tests.

When I import both in a new empty Typescript project them using "npm i @bit/..." they both install OK. Imports from a very basic "index.ts" which compiles and then executes properly.

But I discovered by mistake that every time I compile the main project, source .ts files in the "session" components are compiled by Typescript, not those in the "textcleaning".

Running "tsc --listFiles | grep @bit" confirms this

.../bit-sandbox/node_modules/@bit/olivr70.permnat.textcleaning/dist/index.d.ts
.../bit-sandbox/node_modules/@bit/olivr70.permnat.session/commons.ts
.../bit-sandbox/node_modules/@bit/olivr70.permnat.session/config-session.ts
.../bit-sandbox/node_modules/@bit/olivr70.permnat.session/token.ts
.../bit-sandbox/node_modules/@bit/olivr70.permnat.session/index.ts

The importing project is very simple and only includes my "index.ts" file (listing at the end) tsconfig.json

Expected Behavior

Running "tsc --listFiles | grep @bit" should display

.../bit-sandbox/node_modules/@bit/olivr70.permnat.textcleaning/dist/index.d.ts
.../bit-sandbox/node_modules/@bit/olivr70.permnat.session/dist/index.d.ts

Specifications

Additional context

From my test project, tsconfig.json is very simple

{
    "compilerOptions": {
      "outDir":"./dist/",
        "target":"es2018",
        "moduleResolution":"node",
        "types":[ "jest","node" ],
        "lib":[ "es2018", "dom"]
    },
    "include":[
        "index.ts"
    ]
 }
Rvkstrauss commented 4 years ago

This issue has been resolved in recent typescript-compiler versions. Please reopen if the issue persists after update.