Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect order of extend()ing compilerOptions #27

Closed
terasaka2k opened this issue Nov 6, 2015 · 7 comments
Closed

Incorrect order of extend()ing compilerOptions #27

terasaka2k opened this issue Nov 6, 2015 · 7 comments
Labels

Comments

@terasaka2k
Copy link

In ts-node.ts around line 80,

  config.compilerOptions = extend({
    target: 'es5',
    module: 'commonjs'
  }, config.compilerOptions, {
    sourceMap: true,
    inlineSourceMap: false,
    inlineSources: false,
    declaration: false
  })

should be

  config.compilerOptions = extend({
    sourceMap: true,
    inlineSourceMap: false,
    inlineSources: false,
    declaration: false
  }, config.compilerOptions, {
    target: 'es5',
    module: 'commonjs'
  })

for { target: 'es5', module: 'commonjs' } to take precedence over user's options, which potentially may be intended for latest browsers environments.

@blakeembrey
Copy link
Member

@terasaka2k This is correct. The sourceMap options need to override the user settings, there's specially handling for it. The user, however, could output ES6 or ES3 if they so wished. Same with the module environment.

Edit: Accidentally hit enter.

@darthtrevino
Copy link

Consider this use case: I'm using webpack to chain the typescript-loader and the babel-loader together to take advantage of babel's hook runtime for things like HMR. I want my tsconfig.json to target ES6 and let the babel-loader transpile from ES6 to ES5 for browsers.

However, in my server code, I want to go straight from TS to ES5. I would like to be able to do this:

# index.js - server entry point
require('ts-node').register({
    compilerOptions: {
        target: 'es5'
    }
})

And then what I would expect to happen in ts-node would be something like:

const defaultConfig = { target: 'es5', module: 'commonjs' };
const tsConfigFromFile = readFromTsConfigJson();
Object.assign({}, defaultConfig, tsConfigFromFile, tsConfigFromArgs)

@blakeembrey
Copy link
Member

@darthtrevino I'm not sure who you're responding to, but that's how it works already and the reason I closed the issue. However, there's no compilerOptions pass in to ts-node, it's all from tsconfig.json.

@blakeembrey
Copy link
Member

It sounds like you're actually after a different feature? The ability to pass in compiler options that override tsconfig.json?

@darthtrevino
Copy link

Correct

@blakeembrey
Copy link
Member

@darthtrevino #54

@darthtrevino
Copy link

Sweet! Thanks @blakeembrey !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants