electron-userland / electron-compile

DEPRECATED: Electron supporting package to compile JS and CSS in Electron applications
1.01k stars 98 forks source link

Problem with TypeScript usage #151

Open dkundel opened 7 years ago

dkundel commented 7 years ago

Hi everyone!

I think there is a problem with how TypeScript is being compiled. Effectively definitions aren't properly pulled in. Typically you would use in a TypeScript project a tsconfig.json file. It allows you to explicitly specify some compiler options but it also does a few things implicitly. Like pulling in TypeScript definition files that are in folders such as typings/. This doesn't happen in this case at the moment. It seems like simply the respective lib file and the file to compile are being passed.

As a result code such as:

console.log(__dirname)

doesn't compile since it's complaining that __dirname is not defined as I'm pulling in the node and electron definitions through typings/. If I compile it via tsc with a tsconfig.json everything compiles flawlessly.

My .compilerc

{
  "env": {
    "development": {
      "text/typescript": {
        "module": "commonjs",
        "moduleResolution": "node",
        "target": "es6"
      }
    }
  }
}

My tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "moduleResolution": "node",
    "target": "es6",
    "outDir": "out"
  }
}

I think overall tsconfig.json should be supported just like .babelrc is.

Let me know what you think or if I'm doing something wrong. I think this project is cool and I would love to use it :)

dkundel commented 7 years ago

Any updates here?

ghost commented 7 years ago

I had the same problem, it wasn't picking up the global process, but it turned out to be issues elsewhere in the code that typescript via the editor didn't notice.

In any case, this bug probably fits more in https://github.com/electron/electron-compilers/issues

I think a feature request to support the entire tsconfig.json would go well there too.