Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: conditionally load typescript and tsutils
- Loading branch information
1 parent
64f1217
commit 70172c8
Showing
6 changed files
with
93 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/experimental-utils/src/optional-dependencies/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './tsutils'; | ||
export * from './typescript'; |
12 changes: 12 additions & 0 deletions
12
packages/experimental-utils/src/optional-dependencies/tsutils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type * as tsutilsType from 'tsutils'; | ||
|
||
// Load tsutils if it is available. | ||
const tsutils = ((): typeof tsutilsType | Error => { | ||
try { | ||
return require('tsutils') as typeof tsutilsType; | ||
} catch { | ||
return new Error('Cannot find local tsutils peer depenancy.'); | ||
} | ||
})(); | ||
|
||
export { tsutils }; |
12 changes: 12 additions & 0 deletions
12
packages/experimental-utils/src/optional-dependencies/typescript.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type * as tsType from 'typescript'; | ||
|
||
// Load TypeScript if it is available. | ||
const ts = ((): typeof tsType | Error => { | ||
try { | ||
return require('typescript') as typeof tsType; | ||
} catch { | ||
return new Error('Cannot find local typescript peer depenancy.'); | ||
} | ||
})(); | ||
|
||
export { ts }; |