Skip to content

🎥 Make videos programmatically with React

`@remotion/bundler`: do not crash when TypeScript exposes no `sys` (#10416)

Noah3ace574b98d7
diff --git a/packages/bundler/src/esbuild-loader/index.ts b/packages/bundler/src/esbuild-loader/index.ts
index 6f2e2acc4d..6ded7a3fcf 100644
--- a/packages/bundler/src/esbuild-loader/index.ts
+++ b/packages/bundler/src/esbuild-loader/index.ts
@@ -46,12 +46,13 @@ async function ESBuildLoader(
if (!('tsconfigRaw' in transformOptions) && isTypescriptInstalled()) {
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
const typescript = require('typescript') as typeof import('typescript');
- const tsConfig = typescript.readConfigFile(
- tsConfigPath,
- typescript.sys.readFile,
- );
+ // TypeScript 7 (@typescript/native-preview) does not expose `sys` on the CommonJS export
+ const sys = typescript.sys as typeof typescript.sys | undefined;
+ if (sys) {
+ const tsConfig = typescript.readConfigFile(tsConfigPath, sys.readFile);
- transformOptions.tsconfigRaw = tsConfig.config;
+ transformOptions.tsconfigRaw = tsConfig.config;
+ }
}
// https://github.com/privatenumber/esbuild-loader/pull/107