microsoft / TypeScript-Node-Starter

A reference example for TypeScript and Node with a detailed README describing how to use the two together.
MIT License
11.3k stars 2.76k forks source link

client ts files and server ts files should compile to diffrent target #294

Open clysto opened 4 years ago

clysto commented 4 years ago

In the tsconfig.json:

{
    "compilerOptions": {
        "module": "commonjs",
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,

        /* ----------there---------- */
        "target": "es6",  

        "noImplicitAny": true,
        "moduleResolution": "node",
        "sourceMap": true,
        "outDir": "dist",
        "baseUrl": ".",
        "paths": {
            "*": [
                "node_modules/*",
                "src/types/*"
            ]
        }
    },
    "include": [
        "src/**/*"
    ]
}

Es6 is not supported for some browsers. I think we should compile the frontend code and the backend code separately.

peterblazejewicz commented 4 years ago

Yes, that correct and valid point, if we keep the IE11 as supported target, not for evergreens. I think this is outside of this template focus I believe, to provide fine tuned client side compilation tooling. But someone could propose solution based on the simple RollupJS config for client code (Rollup + TS support plugin exporting to ES5 UMD).

diberry commented 3 years ago

@peterblazejewicz I was thinking about separation of concerns too. It might be easier to contribute without sidetracking if the community knew what the goals and roadmap are. There is a bit of cleanup and updating that could happen...

peterblazejewicz commented 3 years ago

The tsconfig now suppports this layered confguration, so we could have base/server/client and differnt targets in package.json scripts. How does it sounds? The regular client code without the introduction of ES6 complex imports, compiles just fine with tsc, no other tooling required. I'm not thinking about composite projects, for the sake of the simplicity: https://www.typescriptlang.org/docs/handbook/project-references.html