🎥 Make videos programmatically with React
change CWD for bundler
Jonny Burger79a808f5fed6
diff --git a/packages/bundler/src/bundle.ts b/packages/bundler/src/bundle.tsindex c1e6714291..5a926a6318 100644--- a/packages/bundler/src/bundle.ts+++ b/packages/bundler/src/bundle.ts@@ -80,8 +80,13 @@ export const bundle = async (options?: BundleOptions): Promise<string> => {const resolvedRemotionRoot = options?.remotionRoot ?? process.cwd();+const outDir = await prepareOutDir(options?.outDir ?? null);+ // The config might use an override which might use+ // `process.cwd()`. The context should always be the Remotion root+ const currentCwd = process.cwd();+ process.chdir(resolvedRemotionRoot);const [, config] = getConfig({outDir,entryPoint,@@ -91,6 +96,7 @@ export const bundle = async (});const output = await promisified([config]);+ process.chdir(currentCwd);if (!output) {throw new Error('Expected webpack output');}diff --git a/packages/cli/src/load-config.ts b/packages/cli/src/load-config.tsindex 7e4a9edf81..1eebacc96b 100644--- a/packages/cli/src/load-config.ts+++ b/packages/cli/src/load-config.ts@@ -54,8 +54,13 @@ export const loadConfigFile = async (const file = await fs.promises.readFile(out, 'utf8');+ const currentCwd = process.cwd();++ // The config file is always executed from the Remotion root, if `process.cwd()` is being used+ process.chdir(remotionRoot);// eslint-disable-next-line no-evaleval(file);+ process.chdir(currentCwd);await fs.promises.unlink(out);return resolved;