Skip to content

🎥 Make videos programmatically with React

don't clear webpack cache while running dev server

Jonny Burger794bd8da0057
diff --git a/packages/bundler/src/webpack-cache.ts b/packages/bundler/src/webpack-cache.ts
index 18ee6918f5..bad9f0432d 100644
--- a/packages/bundler/src/webpack-cache.ts
+++ b/packages/bundler/src/webpack-cache.ts
@@ -50,6 +50,16 @@ const getWebpackCacheDir = (remotionRoot: string) => {
return path.resolve(dir, 'node_modules/.cache/webpack');
};
+const remotionCacheLocationForEnv = (
+ remotionRoot: string,
+ environment: Environment
+) => {
+ return path.join(
+ getWebpackCacheDir(remotionRoot),
+ getWebpackCacheEnvDir(environment)
+ );
+};
+
const remotionCacheLocation = (
remotionRoot: string,
environment: Environment,
@@ -61,24 +71,22 @@ const remotionCacheLocation = (
);
};
-export const clearCache = (remotionRoot: string) => {
- return fs.promises.rm(getWebpackCacheDir(remotionRoot), {
+export const clearCache = (remotionRoot: string, env: Environment) => {
+ return fs.promises.rm(remotionCacheLocationForEnv(remotionRoot, env), {
recursive: true,
});
};
const getPrefix = (environment: Environment) => {
- return `remotion-v4-${environment}`;
+ return `remotion-v5-${environment}`;
};
-export const getWebpackCacheName = (environment: Environment, hash: string) => {
- if (environment === 'development') {
- return `${getPrefix(environment)}-${hash}`;
- }
+export const getWebpackCacheEnvDir = (environment: Environment) => {
+ return getPrefix(environment);
+};
- // In production, the cache is independent from input props because
- // they are passed over URL params. Speed is mostly important in production.
- return `${getPrefix(environment)}-${hash}`;
+export const getWebpackCacheName = (environment: Environment, hash: string) => {
+ return [getWebpackCacheEnvDir(environment), hash].join(path.sep);
};
const hasOtherCache = ({
diff --git a/packages/cli/src/setup-cache.ts b/packages/cli/src/setup-cache.ts
index 7d26777aa3..9203effa07 100644
--- a/packages/cli/src/setup-cache.ts
+++ b/packages/cli/src/setup-cache.ts
@@ -181,7 +181,7 @@ const bundleOnCli = async ({
{indent, logLevel},
'🧹 Cache disabled but found. Deleting... '
);
- await BundlerInternals.clearCache(remotionRoot);
+ await BundlerInternals.clearCache(remotionRoot, 'production');
}
if (cacheExistedBefore === 'other-exists' && shouldCache) {
@@ -189,7 +189,7 @@ const bundleOnCli = async ({
{indent, logLevel},
'🧹 Webpack config change detected. Clearing cache... '
);
- await BundlerInternals.clearCache(remotionRoot);
+ await BundlerInternals.clearCache(remotionRoot, 'production');
}
const bundleStartTime = Date.now();