1

I'd like to ignore the JavaScript files compiled from TypeScript in my git repo. (That greatly simplifies merging, rebasing, partial commits etc.) The relevant parts of my setup look like this:

tsconfig.json

{
    "compilerOptions": {
      "outDir": "./dist"
    }
}

.gitignore

dist

When installing globally like this:

rm -rf dist
node_modules/.bin/tsc
sudo npm install -g

the gitignored dist folder is not installed. Is there any proper solution to this? The following ones aren't really satisfactory:

  • Comment/uncomment dist in .gitignore before and after sudo npm install -g
  • Cope with parallelly managing ts and js files
3
  • make sure you don't have "noEmit": true, in your tsconfig.json Commented Apr 4, 2019 at 11:08
  • @TWI I have no noEmit set. In any case, I don't think that's relevant to the problem, is it? Commented Apr 4, 2019 at 11:50
  • No I didn't fully understand what npm install -g did, So it appears npm install -g honours .gitignore? This might answer your problem stackoverflow.com/a/24942436/3343178 Commented Apr 4, 2019 at 12:09

1 Answer 1

3

I solved the problem by putting the following into my package.json:

"files": [
  "/dist"
],

Now, only the dist folder and README.md are packaged/installed. Found out about this possibility from a post by Jeff Dickey.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.