Skip to content

🎥 Make videos programmatically with React

Revert "`@remotion/lambda`: Fix how .zip location is specified"

Jonny Burger2b3215108f47
diff --git a/packages/lambda/build.ts b/packages/lambda/build.ts
index 09b46db5a7..4f85cb01bc 100644
--- a/packages/lambda/build.ts
+++ b/packages/lambda/build.ts
@@ -2,6 +2,7 @@ import {BundlerInternals} from '@remotion/bundler';
import {dir} from '@remotion/compositor-linux-arm64-gnu';
import fs, {cpSync, readdirSync} from 'node:fs';
import path from 'node:path';
+import {FUNCTION_ZIP_ARM64} from './src/shared/function-zip-path';
import zl from 'zip-lib';
@@ -56,7 +57,7 @@ fs.cpSync(
`${outdir}/mappings.wasm`,
);
-await zl.archiveFolder(outdir, 'remotionlambda-arm64.zip');
+await zl.archiveFolder(outdir, FUNCTION_ZIP_ARM64);
fs.rmSync(outdir, {recursive: true});
console.log('Bundled Lambda');
diff --git a/packages/lambda/src/api/deploy-function.ts b/packages/lambda/src/api/deploy-function.ts
index 2671720b54..856f254651 100644
--- a/packages/lambda/src/api/deploy-function.ts
+++ b/packages/lambda/src/api/deploy-function.ts
@@ -14,6 +14,7 @@ import type {
} from '@remotion/serverless';
import {VERSION} from 'remotion/version';
import {awsFullClientSpecifics} from '../functions/full-client-implementation';
+import {FUNCTION_ZIP_ARM64} from '../shared/function-zip-path';
import {validateRuntimePreference} from '../shared/get-layers';
import {validateCustomRoleArn} from '../shared/validate-custom-role-arn';
import {validateCloudWatchRetentionPeriod} from '../shared/validate-retention-period';
@@ -86,12 +87,7 @@ export const internalDeployFunction = async <Provider extends CloudProvider>(
const created = await params.fullClientSpecifics.createFunction({
createCloudWatchLogGroup: params.createCloudWatchLogGroup,
region: params.region,
- // Very delicate!
- // this will output to
- // - dist/esm/index.mjs
- // - dist/api/deploy-function.js
- // It only works because both are two levels deep
- zipFile: '../../remotionlambda-arm64.zip',
+ zipFile: FUNCTION_ZIP_ARM64,
functionName,
accountId,
memorySizeInMb: params.memorySizeInMb,
diff --git a/packages/lambda/src/shared/function-zip-path.ts b/packages/lambda/src/shared/function-zip-path.ts
new file mode 100644
index 0000000000..c597f21e91
--- /dev/null
+++ b/packages/lambda/src/shared/function-zip-path.ts
@@ -0,0 +1,12 @@
+// Don't concatenate as we don't want Bun bundler to hardcode this
+import path from 'node:path';
+
+const b = '../';
+const a = 'remotionlambda-arm64.zip';
+
+export const FUNCTION_ZIP_ARM64 = path.resolve(
+ require.resolve(`../` + b),
+ '..',
+ '..',
+ a,
+);
diff --git a/packages/lambda/src/test/integration/zip-path.test.ts b/packages/lambda/src/test/integration/zip-path.test.ts
deleted file mode 100644
index 57e4a126e7..0000000000
--- a/packages/lambda/src/test/integration/zip-path.test.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import {expect, test} from 'bun:test';
-import {readFile} from 'fs/promises';
-import path from 'path';
-
-// Just fixating this so we don't break this in the future
-test('CJS zip path must be two levels deep', async () => {
- const dist = path.join(
- __dirname,
- '..',
- '..',
- '..',
- 'dist',
- 'api',
- 'deploy-function.js',
- );
- const content = await readFile(dist, 'utf-8');
- expect(content).toContain('../../remotionlambda-arm64.zip');
-});
-
-test('ESM zip path must be two levels deep', async () => {
- const dist = path.join(
- __dirname,
- '..',
- '..',
- '..',
- 'dist',
- 'esm',
- 'index.mjs',
- );
- const content = await readFile(dist, 'utf-8');
- expect(content).toContain('../../remotionlambda-arm64.zip');
-});