Skip to content

🎥 Make videos programmatically with React

Make unsupported bun APIs optional

Jonny Burgerb80a9939ffe7
diff --git a/packages/bundler/package.json b/packages/bundler/package.json
index 1586f9c54e..a943563e4b 100644
--- a/packages/bundler/package.json
+++ b/packages/bundler/package.json
@@ -38,6 +38,7 @@
"devDependencies": {
"@jonny/eslint-config": "3.0.266",
"@types/node": "18.14.6",
+ "bun-types": "0.8.0",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.10",
"eslint": "8.42.0",
diff --git a/packages/bundler/tsconfig.json b/packages/bundler/tsconfig.json
index f9f3a25f3c..e9e1f2d683 100644
--- a/packages/bundler/tsconfig.json
+++ b/packages/bundler/tsconfig.json
@@ -4,7 +4,8 @@
"rootDir": "src",
"outDir": "dist",
"jsx": "react-jsx",
- "skipLibCheck": true
+ "skipLibCheck": true,
+ "types": ["bun-types"]
},
"include": ["src"],
"references": [{"path": "../core"}]
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 0c4ebd9f90..599edee936 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -55,6 +55,7 @@
"devDependencies": {
"@jonny/eslint-config": "3.0.266",
"@types/minimist": "^1.2.2",
+ "bun-types": "0.8.0",
"@types/node": "18.14.6",
"@types/prompts": "^2.4.1",
"@types/react": "18.0.26",
diff --git a/packages/cli/src/get-env.ts b/packages/cli/src/get-env.ts
index 8235e14910..d6f4b8116f 100644
--- a/packages/cli/src/get-env.ts
+++ b/packages/cli/src/get-env.ts
@@ -70,7 +70,13 @@ const getEnvForEnvFile = async (
try {
const envFileData = await fs.promises.readFile(envFile);
if (onUpdate) {
- watchEnvFile({processEnv, envFile, onUpdate});
+ if (typeof fs.watchFile === 'undefined') {
+ Log.warn(
+ 'Unsupported feature (fs.watchFile): .env file will not hot reload.',
+ );
+ } else {
+ watchEnvFile({processEnv, envFile, onUpdate});
+ }
}
return {
@@ -121,11 +127,15 @@ export const getEnvironmentVariables = (
const defaultEnvFile = path.resolve(remotionRoot, '.env');
if (!fs.existsSync(defaultEnvFile)) {
if (onUpdate) {
- watchEnvFile({
- processEnv,
- envFile: defaultEnvFile,
- onUpdate,
- });
+ if (typeof fs.watchFile === 'undefined') {
+ Log.warn('Unsupported Bun feature: .env file will not hot reload.');
+ } else {
+ watchEnvFile({
+ processEnv,
+ envFile: defaultEnvFile,
+ onUpdate,
+ });
+ }
}
return Promise.resolve(processEnv);
diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json
index f834553061..de9ca65c7b 100644
--- a/packages/cli/tsconfig.json
+++ b/packages/cli/tsconfig.json
@@ -4,7 +4,8 @@
"rootDir": "src",
"outDir": "dist",
"jsx": "react-jsx",
- "skipLibCheck": true
+ "skipLibCheck": true,
+ "types": ["bun-types"]
},
"references": [
{"path": "../core"},
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5b1175093b..b2aaa467e4 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -145,6 +145,9 @@ importers:
'@types/react-dom':
specifier: 18.0.10
version: 18.0.10
+ bun-types:
+ specifier: 0.8.0
+ version: 0.8.0
eslint:
specifier: 8.42.0
version: 8.42.0
@@ -242,6 +245,9 @@ importers:
'@types/semver':
specifier: ^7.3.4
version: 7.3.8
+ bun-types:
+ specifier: 0.8.0
+ version: 0.8.0
eslint:
specifier: 8.42.0
version: 8.42.0
@@ -10967,6 +10973,10 @@ packages:
ieee754: 1.2.1
dev: false
+ resolution: {integrity: sha512-7QitK+gU5gPm/JmfGVq2wEjVhoT1ZSAl7y0HPqV9kFWuI8AhQ5flaBiAAqKckUHOyXXeRb1WzSETQDuFZLzjSA==}
+ dev: true
+
resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==}
engines: {node: '>=10.16.0'}