Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ import { Module } from 'module';
import * as util from 'util';
import { fileURLToPath } from 'url';

import sourceMapSupport = require('@cspotcode/source-map-support');
import type * as _sourceMapSupport from '@cspotcode/source-map-support';
import { BaseError } from 'make-error';
import type * as _ts from 'typescript';

Expand DownExpand Up@@ -793,6 +793,8 @@ export function create(rawOptions: CreateOptions = {}): Service {
// Install source map support and read from memory cache.
installSourceMapSupport();
function installSourceMapSupport() {
const sourceMapSupport =
require('@cspotcode/source-map-support') as typeof _sourceMapSupport;
sourceMapSupport.install({
environment: 'node',
retrieveFile(pathOrUrl: string) {
Expand Down
11 changes: 9 additions & 2 deletions src/repl.ts
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
import { diffLines } from 'diff';
import type * as _diff from 'diff';
import { homedir } from 'os';
import { join } from 'path';
import {
Expand DownExpand Up@@ -26,6 +26,13 @@ function getProcessTopLevelAwait() {
}
return _processTopLevelAwait;
}
let diff: typeof _diff;
function getDiffLines() {
if (diff === undefined) {
diff = require('diff');
}
return diff.diffLines;
}

/** @internal */
export const EVAL_FILENAME = `[eval].ts`;
Expand DownExpand Up@@ -544,7 +551,7 @@ function appendCompileAndEvalInput(options: {
);

// Use `diff` to check for new JavaScript to execute.
const changes = diffLines(
const changes = getDiffLines()(
oldOutputWithoutSourcemapComment,
outputWithoutSourcemapComment
);
Expand Down