Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: TypeStrong/ts-node
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.2.0
Choose a base ref
...
head repository: TypeStrong/ts-node
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v7.0.0
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Jun 22, 2018

  1. 4
    Copy the full SHA
    33cb1b5 View commit details
  2. 7.0.0

    blakeembrey committed Jun 22, 2018
    Copy the full SHA
    6ce7c97 View commit details
Showing with 22 additions and 14 deletions.
  1. +2 −0 README.md
  2. +1 −1 package-lock.json
  3. +1 −1 package.json
  4. +18 −12 src/index.ts
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@

> TypeScript execution and REPL for node.js, with source map support. **Works with `typescript@>=2.0`**.
**Tip:** `ts-node` differs slightly from `tsc`. It will not load files from `tsconfig.json` by default. Instead, `ts-node` starts from the input file and discovers the rest of the project tree through imports and references.

## Installation

```sh
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-node",
"version": "6.2.0",
"version": "7.0.0",
"description": "TypeScript execution environment and REPL for node.js, with source map support",
"main": "dist/index.js",
"types": "dist/index.d.ts",
30 changes: 18 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ export interface TypeInfo {
* Default register options.
*/
export const DEFAULTS: Options = {
files: yn(process.env['TS_NODE_FILES'], { default: true }),
files: yn(process.env['TS_NODE_FILES']),
cache: yn(process.env['TS_NODE_CACHE'], { default: true }),
pretty: yn(process.env['TS_NODE_PRETTY']),
cacheDirectory: process.env['TS_NODE_CACHE_DIRECTORY'],
@@ -231,10 +231,18 @@ export function register (opts: Options = {}): Register {
const config = readConfig(cwd, ts, fileExists, readFile, compilerOptions, project, skipProject)
const configDiagnosticList = filterDiagnostics(config.errors, ignoreDiagnostics)
const extensions = ['.ts', '.tsx']
const fileNames = options.files ? config.fileNames : []

const cachedir = join(
resolve(cwd, cacheDirectory),
getCompilerDigest({ version: ts.version, typeCheck, ignoreDiagnostics, config, compiler })
getCompilerDigest({
version: ts.version,
options: config.options,
fileNames,
typeCheck,
ignoreDiagnostics,
compiler
})
)

const diagnosticHost: _ts.FormatDiagnosticsHost = {
@@ -262,12 +270,8 @@ export function register (opts: Options = {}): Register {
extensions.push('.jsx')
}

// Add all files into the file hash.
if (options.files) {
for (const fileName of config.fileNames) {
memoryCache.versions[fileName] = 1
}
}
// Initialize files from TypeScript into project.
for (const path of fileNames) memoryCache.versions[path] = 1

/**
* Get the extension for a transpiled file.
@@ -442,7 +446,7 @@ function registerExtension (
/**
* Do post-processing on config options to support `ts-node`.
*/
function fixConfig (ts: TSCommon, config: any) {
function fixConfig (ts: TSCommon, config: _ts.ParsedCommandLine) {
// Delete options that *should not* be passed through.
delete config.options.out
delete config.options.outFile
@@ -474,7 +478,7 @@ function readConfig (
compilerOptions?: object,
project?: string | null,
noProject?: boolean | null
) {
): _ts.ParsedCommandLine {
let config = { compilerOptions: {} }
let basePath = normalizeSlashes(cwd)
let configFileName: string | undefined = undefined
@@ -489,7 +493,9 @@ function readConfig (
const result = ts.readConfigFile(configFileName, readFile)

// Return diagnostics.
if (result.error) return { errors: [result.error] }
if (result.error) {
return { errors: [result.error], fileNames: [], options: {} }
}

config = result.config
basePath = normalizeSlashes(dirname(configFileName))
@@ -586,7 +592,7 @@ function updateSourceMap (sourceMapText: string, fileName: string) {
function getCacheName (sourceCode: string, fileName: string) {
return crypto.createHash('sha256')
.update(extname(fileName), 'utf8')
.update('\x001\x00', 'utf8') // Store "cache version" in hash.
.update('\x00', 'utf8')
.update(sourceCode, 'utf8')
.digest('hex')
}