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: v1.5.1
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: v1.5.2
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Oct 15, 2016

  1. Try to parse files without any extension as TS

    Re-enables people using `ts-node` for bin executables.
    blakeembrey committed Oct 15, 2016
    Copy the full SHA
    e09d5ca View commit details
  2. v1.5.2

    blakeembrey committed Oct 15, 2016
    Copy the full SHA
    5786398 View commit details
Showing with 13 additions and 7 deletions.
  1. +1 −1 package.json
  2. +12 −6 src/index.ts
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": "1.5.1",
"version": "1.5.2",
"preferGlobal": true,
"description": "TypeScript execution environment and REPL for node",
"main": "dist/index.js",
18 changes: 12 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -147,6 +147,7 @@ export function register (options: Options = {}): () => Register {
const project = options.project || DEFAULTS.project
const cacheDirectory = options.cacheDirectory || DEFAULTS.cacheDirectory || join(tmpdir(), 'ts-node')
const compilerOptions = extend(DEFAULTS.compilerOptions, options.compilerOptions)
const originalJsHandler = require.extensions['.js']
let result: Register

const ignore = (
@@ -197,7 +198,7 @@ export function register (options: Options = {}): () => Register {
// Enable `allowJs` when flag is set.
if (config.options.allowJs) {
extensions.push('.js')
registerExtension('.js', ignore, service)
registerExtension('.js', ignore, service, originalJsHandler)
}

// Add all files into the file hash.
@@ -359,8 +360,8 @@ export function register (options: Options = {}): () => Register {
}

// Eagerly register TypeScript extensions (JavaScript is registered lazily).
registerExtension('.ts', ignore, service)
registerExtension('.tsx', ignore, service)
registerExtension('.ts', ignore, service, originalJsHandler)
registerExtension('.tsx', ignore, service, originalJsHandler)

// Immediately initialize the TypeScript compiler.
if (!options.lazy) {
@@ -377,7 +378,7 @@ function shouldIgnore (filename: string, ignore: RegExp[], service: () => Regist
const relname = slash(filename)
const extension = extname(filename)

if (service().extensions.indexOf(extension) > -1) {
if (!extension || service().extensions.indexOf(extension) > -1) {
return ignore.some(x => x.test(relname))
}

@@ -387,8 +388,13 @@ function shouldIgnore (filename: string, ignore: RegExp[], service: () => Regist
/**
* Register the extension for node.
*/
function registerExtension (ext: string, ignore: RegExp[], service: () => Register) {
const old = require.extensions[ext] || require.extensions['.js']
function registerExtension (
ext: string,
ignore: RegExp[],
service: () => Register,
originalHandler: (m: NodeModule, filename: string) => any
) {
const old = require.extensions[ext] || originalHandler

require.extensions[ext] = function (m, filename) {
if (shouldIgnore(filename, ignore, service)) {