TypeStrong / grunt-ts

A grunt task to manage your complete typescript development to production workflow
https://www.npmjs.com/package/grunt-ts
MIT License
330 stars 121 forks source link

Compile all *.server.ts files but leave *.client.ts files untouched ? #351

Closed daslicht closed 8 years ago

daslicht commented 8 years ago

Hi, lets say we have the following naming schema of files:

main.server.ts
main.client.ts

Is it possible to compile to just compile all .server.ts files and leave the .client.ts files untouched ?

related: http://stackoverflow.com/questions/36436676/how-to-compile-all-files-with-the-extension-server-ts-only

nycdotnet commented 8 years ago

Consider something like this in your gruntfile:

ts: {
  compileClient : {
    src: ["**/*.client.ts", "!node_modules/**/*.ts"]
  },
  compileServer : {
    src: ["**/*.server.ts", "!node_modules/**/*.ts"]
  }
}

You'd then be able to run grunt ts:compileServer or grunt ts:compileClient and it compile the appropriate set of files. To make Atom leave the files alone, you can disable compile on save - see here: https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#compileonsave

daslicht commented 8 years ago

Uhh Oh thats the missing link. disable compile an save!

Does that also prevent Atom from showing the warning that the files are missing in the tsconfig ?

eg:

My current plan was to use browserify to bundle the client ts files. Will Grunt-ts also bundle the imports into one file so that I can use it in the browser? How would I have to load them ? Do I need a Loader like SystemJS or could I just use them like a browserify bundle?

Thank you !

daslicht commented 8 years ago

Just tested :

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "sourceMap": true
    },

    "atom": {
        "rewriteTsconfig": true,
        "buildOnSave": false
    }
}

no more compiler warnings :) I am going to try Grunt later when having more time

Thank You !

nycdotnet commented 8 years ago

Note: compileOnSave under compilerOptions is the one you want. buildOnSave defaults to false already. compileOnSave controls "save one .ts file, emit one .js file". buildOnSave controls "save one .ts file, emit all the .js files".

daslicht commented 8 years ago

Thank you !