Skip to content

🎥 Make videos programmatically with React

no need to write config file to FS

Jonny Burger0c55bd6fc77e
diff --git a/packages/cli/src/load-config.ts b/packages/cli/src/load-config.ts
index 29a8ce3cd4..b511b059ef 100644
--- a/packages/cli/src/load-config.ts
+++ b/packages/cli/src/load-config.ts
@@ -1,6 +1,5 @@
import {BundlerInternals} from '@remotion/bundler';
import fs from 'fs';
-import os from 'os';
import path from 'path';
import {isMainThread} from 'worker_threads';
import {Log} from './log';
@@ -21,10 +20,7 @@ export const loadConfigFile = async (
process.exit(1);
}
- const out = path.join(
- await fs.promises.mkdtemp(path.join(os.tmpdir(), 'remotion-')),
- 'bundle.js'
- );
+ const virtualOutfile = 'bundle.js';
const result = await BundlerInternals.esbuild.build({
platform: 'node',
target: 'node14',
@@ -32,7 +28,8 @@ export const loadConfigFile = async (
entryPoints: [resolved],
tsconfig: isJavascript ? undefined : tsconfigJson,
absWorkingDir: remotionRoot,
- outfile: out,
+ outfile: virtualOutfile,
+ write: false,
packages: 'external',
});
if (result.errors.length > 0) {
@@ -44,7 +41,7 @@ export const loadConfigFile = async (
process.exit(1);
}
- const file = await fs.promises.readFile(out, 'utf8');
+ const str = new TextDecoder().decode(result.outputFiles[0].contents);
const currentCwd = process.cwd();
@@ -55,12 +52,11 @@ export const loadConfigFile = async (
// Exectute the contents of the config file
// eslint-disable-next-line no-eval
- eval(file);
+ eval(str);
if (isMainThread) {
process.chdir(currentCwd);
}
- await fs.promises.unlink(out);
return resolved;
};