Skip to content

Commit 3499611

Browse files
authored
fix(register): do not send undefined source code for compilation (#797)
1 parent 9644be5 commit 3499611

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/register/register.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ const injectInlineSourceMap = ({
4747
}
4848

4949
export function compile(
50-
sourcecode: string,
50+
sourcecode: string | undefined,
5151
filename: string,
5252
options: ts.CompilerOptions & {
5353
fallbackToTs?: (filename: string) => boolean
5454
},
5555
): string
5656

5757
export function compile(
58-
sourcecode: string,
58+
sourcecode: string | undefined,
5959
filename: string,
6060
options: ts.CompilerOptions & {
6161
fallbackToTs?: (filename: string) => boolean
@@ -64,7 +64,7 @@ export function compile(
6464
): string
6565

6666
export function compile(
67-
sourcecode: string,
67+
sourcecode: string | undefined,
6868
filename: string,
6969
options: ts.CompilerOptions & {
7070
fallbackToTs?: (filename: string) => boolean
@@ -73,7 +73,7 @@ export function compile(
7373
): Promise<string>
7474

7575
export function compile(
76-
sourcecode: string,
76+
sourcecode: string | undefined,
7777
filename: string,
7878
options: ts.CompilerOptions & {
7979
fallbackToTs?: (filename: string) => boolean
@@ -82,14 +82,15 @@ export function compile(
8282
): string | Promise<string>
8383

8484
export function compile(
85-
sourcecode: string,
85+
sourcecode: string | undefined,
8686
filename: string,
8787
options: ts.CompilerOptions & {
8888
fallbackToTs?: (filename: string) => boolean
8989
},
9090
async = false,
9191
) {
9292
if (
93+
typeof sourcecode === 'undefined' ||
9394
(filename.includes('node_modules') && !AVAILABLE_TS_EXTENSION_PATTERN.test(filename)) ||
9495
!AVAILABLE_EXTENSION_PATTERN.test(filename)
9596
) {

0 commit comments

Comments
 (0)