Skip to content

Commit

Permalink
feat: drop ts-node dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Sep 25, 2023
1 parent e1632db commit ab82b6e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
"strip-ansi": "^6.0.1",
"supports-color": "^8.1.1",
"supports-hyperlinks": "^2.2.0",
"ts-node": "^10.9.1",
"tslib": "^2.5.0",
"widest-line": "^3.1.0",
"wordwrap": "^1.0.0",
"wrap-ansi": "^7.0.0"
Expand Down Expand Up @@ -72,6 +70,8 @@
"shx": "^0.3.4",
"sinon": "^11.1.2",
"tsd": "^0.29.0",
"ts-node": "^10.9.1",
"tslib": "^2.5.0",
"typescript": "^5"
},
"engines": {
Expand Down
16 changes: 14 additions & 2 deletions src/config/ts-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ function loadTSConfig(root: string): TSConfig | undefined {
} catch {
try {
typescript = require(join(root, 'node_modules', 'typescript'))
} catch {}
} catch {
debug(`Could not find typescript dependency. Skipping ts-node registration for ${root}.`)
memoizedWarn('Could not find typescript. Please ensure that typescript is a devDependency. Falling back to compiled source.')
return
}
}

if (existsSync(tsconfigPath) && typescript) {
Expand All @@ -49,7 +53,15 @@ function registerTSNode(root: string): TSConfig | undefined {
debug('registering ts-node at', root)
const tsNodePath = require.resolve('ts-node', {paths: [root, __dirname]})
debug('ts-node path:', tsNodePath)
const tsNode: typeof TSNode = require(tsNodePath)
let tsNode: typeof TSNode

try {
tsNode = require(tsNodePath)
} catch {
debug(`Could not find ts-node at ${tsNodePath}. Skipping ts-node registration for ${root}.`)
memoizedWarn(`Could not find ts-node at ${tsNodePath}. Please ensure that ts-node is a devDependency. Falling back to compiled source.`)
return
}

const typeRoots = [
join(root, 'node_modules', '@types'),
Expand Down

0 comments on commit ab82b6e

Please sign in to comment.