2

I've been working on a TypeScript project for a while and I was using browserify (watchify) and it was working fine, but then just now I was trying to trim down some dependencies and I don't think I should need these to build a TypeScript project. So, instead of using this command (which was working):

watchify src/index.ts -p [ tsify --watch ] -o bin/bundle.js

I thought to just try this:

tsc

And I also tried

tsc --build

But the issue is that.. those commands don't seem to do anything. My command prompt thinks for a couple seconds, and then returns. No errors, but also no bundle.js either.

My tsconfig.json (which was also being used by watchify and worked fine there), looks like this:

{
  "parser": "babel-eslint",
  "parserOptions": {
    "sourceType": "module",
    "allowImportExportEverywhere": true
  },
  "compileOnSave": true,
  "compilerOptions": {
      "downlevelIteration": true,
      "allowJs": false,
      "outDir": "bin",
      "module": "commonjs",
      "lib": [ "es5", "es6", "dom", "es2017" ],
      "noImplicitAny": false,
      "removeComments": true,
      "preserveConstEnums": true,
      "sourceMap": true,
      "target": "es5",
      "watch": true,
      "resolveJsonModule": true,
      "suppressImplicitAnyIndexErrors": true
  },
  "include": [
    "src/*"
  ]
}

Any idea why this might be happening? I feel like I shouldn't need browserify or watchify or any of that stuff. Shouldn't I just be able to type tsc and have it create a bundle file? If so, why isn't it .. doing anything..?

1 Answer 1

2

"parser": "babel-eslint" will most likely not do anything if you don't actually have babel installed and if the tsc files aren't actually passed to babel (which is what watchify was probably doing). Remove that option completely from tsconfig.json.

"outDir": "bin" this is telling typescript to compile all files from rootDir (which is not set so it's default '.'), that uses the pattern "src/*", from your include, then to put all of the compiled files in ./bin. The files will not compile to any sort of build.js file and they will all be compiled as individual files and stored in /bin. If you want to compile it to a single file you need "outFile": "build.js" which can also only work with "module": "system".

This tsconfig.json file was likely never used by watchify and it probably used its own one by the looks of it (I don't know anything about watchify).

If none of that helps you get anywhere then enable debugging and see what it's telling you.

  "diagnostics": true,
  "extendedDiagnostics": true,
  "explainFiles": false,
  "listEmittedFiles": true,
  "listFiles": false,
  "traceResolution": false,
  "disableReferencedProjectLoad": false,
  "disableSolutionSearching": false,
  "noErrorTruncation": true,
  "preserveWatchOutput": false,
  "pretty": true
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.