🎥 Make videos programmatically with React
`@remotion/lambda` + `@remotion/renderer`: Provide ESM exports of packages
Jonny Burger0e6ea21d1e55
diff --git a/packages/.monorepo/builder.ts b/packages/.monorepo/builder.tsindex 804b913d34..8c27f0b3aa 100644--- a/packages/.monorepo/builder.ts+++ b/packages/.monorepo/builder.ts@@ -10,9 +10,11 @@ type Format = 'esm' | 'cjs';const getExternal = (deps: string[] | 'dependencies'): string[] => {if (deps === 'dependencies') {- return Object.keys(- require(path.join(process.cwd(), 'package.json')).dependencies,- );+ const packageJson = require(path.join(process.cwd(), 'package.json'));+ return Object.keys({+ ...(packageJson.dependencies ?? {}),+ ...(packageJson.optionalDependencies ?? {}),+ });}return deps;diff --git a/packages/cloudrun/build.ts b/packages/cloudrun/build.tsindex 0e3f169b17..16041f9698 100644--- a/packages/cloudrun/build.ts+++ b/packages/cloudrun/build.ts@@ -1,9 +1,6 @@-import {$} from 'bun';import {bundleInstaller} from './src/admin/bundle-installer';import {bundleRenderLogic} from './src/admin/bundle-renderLogic';-await $`bun x tsc -d`;-const permissions = Bun.file('src/shared/sa-permissions.json');await Bun.write('dist/shared/sa-permissions.json', permissions);diff --git a/packages/cloudrun/package.json b/packages/cloudrun/package.jsonindex 1f0e2c68b4..eb8b0933ba 100644--- a/packages/cloudrun/package.json+++ b/packages/cloudrun/package.json@@ -8,12 +8,11 @@"main": "dist/index.js","sideEffects": false,"scripts": {- "make": "tsc -d && bun build.ts",- "buildContainer": "bun src/admin/bundle-renderLogic.ts",- "tarInstaller": "bun src/admin/bundle-installer.ts",+ "make": "tsc -d",+ "makeruntime": "bun build.ts","lint": "eslint src","test": "bun test src",- "publish": "cd container && ARTIFACT_REGISTRY_ENV=production node submit.mjs"+ "publish": "bun build.ts cd container && ARTIFACT_REGISTRY_ENV=production node submit.mjs"},"dependencies": {"@google-cloud/artifact-registry": "^3.4.0",diff --git a/packages/cloudrun/src/admin/bundle-renderLogic.ts b/packages/cloudrun/src/admin/bundle-renderLogic.tsindex b3fdff88ff..6b6eb8a283 100644--- a/packages/cloudrun/src/admin/bundle-renderLogic.ts+++ b/packages/cloudrun/src/admin/bundle-renderLogic.ts@@ -12,7 +12,9 @@ export const bundleRenderLogic = async () => {(fs.rmSync ?? fs.rmdirSync)(outdir, {recursive: true});fs.mkdirSync(outdir, {recursive: true});- const template = require.resolve(path.join(__dirname, '../functions/index'));+ const template = require.resolve(+ path.join(__dirname, '../../dist/functions/index'),+ );await BundlerInternals.esbuild.build({platform: 'node',diff --git a/packages/example/runcloudrun.sh b/packages/example/runcloudrun.shindex 7bde42e435..6ce282dbf8 100644--- a/packages/example/runcloudrun.sh+++ b/packages/example/runcloudrun.sh@@ -5,6 +5,7 @@ bun build.ts --cloudruncd ..cd cloudrunbun run make+bun run makeruntimecd containerARTIFACT_REGISTRY_ENV=development node submit.mjscd ..diff --git a/packages/example/runlambda.sh b/packages/example/runlambda.shindex 8cd3cb29a9..815fbb2b99 100644--- a/packages/example/runlambda.sh+++ b/packages/example/runlambda.sh@@ -2,6 +2,7 @@ set -ecd ..cd lambdabun run make+bun run makeruntimecd ..cd examplebunx remotion lambda functions rmall -fdiff --git a/packages/it-tests/src/monorepo/esm.test.ts b/packages/it-tests/src/monorepo/esm.test.tsindex efd26ab9d2..3ad328e283 100644--- a/packages/it-tests/src/monorepo/esm.test.ts+++ b/packages/it-tests/src/monorepo/esm.test.ts@@ -30,6 +30,12 @@ test('Should be able to "import" frontend in node', async () => {execSync(`node --input-type=module -e "import {measureText} from '@remotion/layout-utils'; console.log(measureText)"`,);+ execSync(+ `node --input-type=module -e "import {getRenderProgress} from '@remotion/lambda/client'; console.log(getRenderProgress)"`,+ );+ execSync(+ `node --input-type=module -e "import {getRenderProgress} from '@remotion/lambda'; console.log(getRenderProgress)"`,+ );execSync(`node --input-type=module -e "import {loadFont} from '@remotion/google-fonts/Montserrat'; console.log(loadFont)"`,);diff --git a/packages/lambda/bundle.ts b/packages/lambda/bundle.tsnew file mode 100644index 0000000000..8ac9a30bf2--- /dev/null+++ b/packages/lambda/bundle.ts@@ -0,0 +1,23 @@+import {buildPackage} from '../.monorepo/builder';++await buildPackage({+ formats: {+ cjs: 'use-tsc',+ esm: 'build',+ },+ external: 'dependencies',+ entrypoints: [+ {+ path: 'src/index.ts',+ target: 'node',+ },+ {+ path: 'src/client.ts',+ target: 'node',+ },+ {+ path: 'src/policies.ts',+ target: 'node',+ },+ ],+});diff --git a/packages/lambda/package.json b/packages/lambda/package.jsonindex f111aa9ad5..1c9b688524 100644--- a/packages/lambda/package.json+++ b/packages/lambda/package.json@@ -12,7 +12,8 @@"lint": "eslint src","testlambda": "exit 0","test": "bun test src/test/unit",- "make": "tsc -d && bun build.ts",+ "make": "tsc -d && bun --env-file=../.env.bundle bundle.ts",+ "makeruntime": "bun build.ts","prepublishOnly": "bun build.ts && bun ensure-version-match.js"},"author": "Jonny Burger <[email protected]>",@@ -60,17 +61,32 @@},"exports": {"./package.json": "./package.json",- ".": "./dist/index.js",- "./policies": "./dist/api/iam-validation/suggested-policy.js",- "./client": "./dist/client.js"+ ".": {+ "types": "./dist/index.d.ts",+ "require": "./dist/index.js",+ "module": "./dist/esm/index.mjs",+ "import": "./dist/esm/index.mjs"+ },+ "./client": {+ "types": "./dist/client.d.ts",+ "require": "./dist/client.js",+ "module": "./dist/esm/client.mjs",+ "import": "./dist/esm/client.mjs"+ },+ "./policies": {+ "types": "./dist/policies.d.ts",+ "require": "./dist/policies.js",+ "module": "./dist/esm/policies.mjs",+ "import": "./dist/esm/policies.mjs"+ }},"typesVersions": {">=1.0": {- "policies": [- "dist/api/iam-validation/suggested-policy.d.ts"- ],"client": ["dist/client.d.ts"+ ],+ "policies": [+ "dist/policies.d.ts"]}},diff --git a/packages/lambda/src/api/create-function.ts b/packages/lambda/src/api/create-function.tsindex 5fd3b1f50e..ae2fa3ae61 100644--- a/packages/lambda/src/api/create-function.ts+++ b/packages/lambda/src/api/create-function.ts@@ -15,11 +15,11 @@ import {type AwsRegion,type RuntimePreference,} from '@remotion/lambda-client';+import {LOG_GROUP_PREFIX} from '@remotion/lambda-client/constants';import type {LogLevel} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';import {readFileSync} from 'node:fs';import {VERSION} from 'remotion/version';-import {LOG_GROUP_PREFIX} from '../defaults';import {getLayers} from '../shared/get-layers';import {lambdaInsightsExtensions} from '../shared/lambda-insights-extensions';import {ROLE_NAME} from './iam-validation/suggested-policy';diff --git a/packages/lambda/src/api/delete-site.ts b/packages/lambda/src/api/delete-site.tsindex 421e7b1b60..49e2761f7f 100644--- a/packages/lambda/src/api/delete-site.ts+++ b/packages/lambda/src/api/delete-site.ts@@ -1,7 +1,7 @@import type {AwsRegion} from '@remotion/lambda-client';import {LambdaClientInternals, type AwsProvider} from '@remotion/lambda-client';+import {getSitesKey} from '@remotion/lambda-client/constants';import type {ProviderSpecifics} from '@remotion/serverless';-import {getSitesKey} from '../defaults';type MandatoryParameters = {bucketName: string;diff --git a/packages/lambda/src/api/deploy-function.ts b/packages/lambda/src/api/deploy-function.tsindex bc0b6ce1cb..856f254651 100644--- a/packages/lambda/src/api/deploy-function.ts+++ b/packages/lambda/src/api/deploy-function.ts@@ -4,6 +4,7 @@ import {speculateFunctionName,type AwsRegion,} from '@remotion/lambda-client';+import {DEFAULT_EPHEMERAL_STORAGE_IN_MB} from '@remotion/lambda-client/constants';import type {LogLevel} from '@remotion/renderer';import {wrapWithErrorHandling} from '@remotion/renderer/error-handling';import type {@@ -12,7 +13,6 @@ import type {ProviderSpecifics,} from '@remotion/serverless';import {VERSION} from 'remotion/version';-import {DEFAULT_EPHEMERAL_STORAGE_IN_MB} from '../defaults';import {awsFullClientSpecifics} from '../functions/full-client-implementation';import {FUNCTION_ZIP_ARM64} from '../shared/function-zip-path';import {validateRuntimePreference} from '../shared/get-layers';diff --git a/packages/lambda/src/api/deploy-site.ts b/packages/lambda/src/api/deploy-site.tsindex ec2cbe8cdd..6367aa3015 100644--- a/packages/lambda/src/api/deploy-site.ts+++ b/packages/lambda/src/api/deploy-site.ts@@ -1,6 +1,10 @@import {type GitSource, type WebpackOverrideFn} from '@remotion/bundler';import type {AwsRegion} from '@remotion/lambda-client';import {LambdaClientInternals, type AwsProvider} from '@remotion/lambda-client';+import {+ getSitesKey,+ REMOTION_BUCKET_PREFIX,+} from '@remotion/lambda-client/constants';import type {ToOptions} from '@remotion/renderer';import type {BrowserSafeApis} from '@remotion/renderer/client';import {wrapWithErrorHandling} from '@remotion/renderer/error-handling';@@ -11,7 +15,6 @@ import type {} from '@remotion/serverless';import {validateBucketName, validatePrivacy} from '@remotion/serverless';import fs from 'node:fs';-import {getSitesKey, REMOTION_BUCKET_PREFIX} from '../defaults';import {awsFullClientSpecifics} from '../functions/full-client-implementation';import {getS3DiffOperations} from '../shared/get-s3-operations';import {validateSiteName} from '../shared/validate-site-name';diff --git a/packages/lambda/src/api/download-media.ts b/packages/lambda/src/api/download-media.tsindex 94240a4016..887587177c 100644--- a/packages/lambda/src/api/download-media.ts+++ b/packages/lambda/src/api/download-media.ts@@ -1,5 +1,6 @@import type {AwsRegion} from '@remotion/lambda-client';import {LambdaClientInternals, type AwsProvider} from '@remotion/lambda-client';+import {REMOTION_BUCKET_PREFIX} from '@remotion/lambda-client/constants';import type {LogLevel} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';import type {ProviderSpecifics} from '@remotion/serverless';@@ -9,7 +10,6 @@ import {type CustomCredentials,} from '@remotion/serverless';import path from 'node:path';-import {REMOTION_BUCKET_PREFIX} from '../defaults';import type {LambdaReadFileProgress} from '../functions/helpers/read-with-progress';import {lambdaDownloadFileWithProgress} from '../functions/helpers/read-with-progress';diff --git a/packages/lambda/src/api/get-function-info.ts b/packages/lambda/src/api/get-function-info.tsindex 0eab171489..07dfcf39be 100644--- a/packages/lambda/src/api/get-function-info.ts+++ b/packages/lambda/src/api/get-function-info.ts@@ -4,9 +4,9 @@ import {getFunctionVersion,LambdaClientInternals,} from '@remotion/lambda-client';+import {DEFAULT_EPHEMERAL_STORAGE_IN_MB} from '@remotion/lambda-client/constants';import type {LogLevel} from '@remotion/renderer';import type {FunctionInfo} from '@remotion/serverless';-import {DEFAULT_EPHEMERAL_STORAGE_IN_MB} from '../defaults';export type GetFunctionInfoInput = {region: AwsRegion;diff --git a/packages/lambda/src/api/iam-validation/role-permissions.ts b/packages/lambda/src/api/iam-validation/role-permissions.tsindex f902fb6a93..df0b5d24d4 100644--- a/packages/lambda/src/api/iam-validation/role-permissions.ts+++ b/packages/lambda/src/api/iam-validation/role-permissions.ts@@ -3,7 +3,7 @@ import {LOG_GROUP_PREFIX,REMOTION_BUCKET_PREFIX,RENDER_FN_PREFIX,-} from '../../defaults';+} from '@remotion/lambda-client/constants';export const rolePermissions: {actions: string[];diff --git a/packages/lambda/src/api/iam-validation/user-permissions.ts b/packages/lambda/src/api/iam-validation/user-permissions.tsindex 2da1c29db3..1797d6094d 100644--- a/packages/lambda/src/api/iam-validation/user-permissions.ts+++ b/packages/lambda/src/api/iam-validation/user-permissions.ts@@ -2,7 +2,7 @@ import {LOG_GROUP_PREFIX,REMOTION_BUCKET_PREFIX,RENDER_FN_PREFIX,-} from '../../defaults';+} from '@remotion/lambda-client/constants';import {REMOTION_HOSTED_LAYER_ARN} from '../../shared/hosted-layers';export const requiredPermissions: {diff --git a/packages/lambda/src/cli/commands/compositions/index.ts b/packages/lambda/src/cli/commands/compositions/index.tsindex 5c3ddc8867..7825fa111a 100644--- a/packages/lambda/src/cli/commands/compositions/index.ts+++ b/packages/lambda/src/cli/commands/compositions/index.ts@@ -4,10 +4,10 @@ import {getCompositionsOnLambda,LambdaClientInternals,} from '@remotion/lambda-client';+import {BINARY_NAME} from '@remotion/lambda-client/constants';import type {ChromiumOptions, LogLevel} from '@remotion/renderer';import {BrowserSafeApis} from '@remotion/renderer/client';import {ProviderSpecifics} from '@remotion/serverless';-import {BINARY_NAME} from '../../../defaults';import {parsedLambdaCli} from '../../args';import {getAwsRegion} from '../../get-aws-region';import {findFunctionName} from '../../helpers/find-function-name';diff --git a/packages/lambda/src/cli/commands/functions/deploy.ts b/packages/lambda/src/cli/commands/functions/deploy.tsindex ac4137481c..c047e7d850 100644--- a/packages/lambda/src/cli/commands/functions/deploy.ts+++ b/packages/lambda/src/cli/commands/functions/deploy.ts@@ -1,15 +1,15 @@import {CliInternals} from '@remotion/cli';import {AwsProvider, LambdaClientInternals} from '@remotion/lambda-client';-import type {LogLevel} from '@remotion/renderer';-import {FullClientSpecifics, ProviderSpecifics} from '@remotion/serverless';-import {VERSION} from 'remotion/version';-import {internalDeployFunction} from '../../../api/deploy-function';import {DEFAULT_CLOUDWATCH_RETENTION_PERIOD,DEFAULT_EPHEMERAL_STORAGE_IN_MB,DEFAULT_MEMORY_SIZE,DEFAULT_TIMEOUT,-} from '../../../defaults';+} from '@remotion/lambda-client/constants';+import type {LogLevel} from '@remotion/renderer';+import {FullClientSpecifics, ProviderSpecifics} from '@remotion/serverless';+import {VERSION} from 'remotion/version';+import {internalDeployFunction} from '../../../api/deploy-function';import {validateCustomRoleArn} from '../../../shared/validate-custom-role-arn';import {validateTimeout} from '../../../shared/validate-timeout';import {validateVpcSecurityGroupIds} from '../../../shared/validate-vpc-security-group-ids';diff --git a/packages/lambda/src/cli/commands/functions/index.ts b/packages/lambda/src/cli/commands/functions/index.tsindex 6d06a4ed5a..36d5699549 100644--- a/packages/lambda/src/cli/commands/functions/index.ts+++ b/packages/lambda/src/cli/commands/functions/index.ts@@ -1,8 +1,8 @@import {CliInternals} from '@remotion/cli';+import {BINARY_NAME} from '@remotion/lambda-client/constants';import type {LogLevel} from '@remotion/renderer';import {FullClientSpecifics, ProviderSpecifics} from '@remotion/serverless';import {AwsProvider} from '../../../client';-import {BINARY_NAME} from '../../../defaults';import {quit} from '../../helpers/quit';import {FUNCTIONS_DEPLOY_SUBCOMMAND, functionsDeploySubcommand} from './deploy';import {FUNCTIONS_LS_SUBCOMMAND, functionsLsCommand} from './ls';diff --git a/packages/lambda/src/cli/commands/functions/rm.ts b/packages/lambda/src/cli/commands/functions/rm.tsindex 89fe1b29a1..4b9e0afcba 100644--- a/packages/lambda/src/cli/commands/functions/rm.ts+++ b/packages/lambda/src/cli/commands/functions/rm.ts@@ -1,8 +1,8 @@import {CliInternals} from '@remotion/cli';import {deleteFunction} from '@remotion/lambda-client';+import {BINARY_NAME} from '@remotion/lambda-client/constants';import type {LogLevel} from '@remotion/renderer';import {getFunctionInfo} from '../../../api/get-function-info';-import {BINARY_NAME} from '../../../defaults';import {getAwsRegion} from '../../get-aws-region';import {confirmCli} from '../../helpers/confirm';import {quit} from '../../helpers/quit';diff --git a/packages/lambda/src/cli/commands/policies/policies.ts b/packages/lambda/src/cli/commands/policies/policies.tsindex 3863ac9c94..5d98da8c15 100644--- a/packages/lambda/src/cli/commands/policies/policies.ts+++ b/packages/lambda/src/cli/commands/policies/policies.ts@@ -1,6 +1,6 @@import {CliInternals} from '@remotion/cli';+import {BINARY_NAME} from '@remotion/lambda-client/constants';import type {LogLevel} from '@remotion/renderer';-import {BINARY_NAME} from '../../../defaults';import {quit} from '../../helpers/quit';import {Log} from '../../log';import {ROLE_SUBCOMMAND, roleSubcommand} from './role';diff --git a/packages/lambda/src/cli/commands/quotas/increase.ts b/packages/lambda/src/cli/commands/quotas/increase.tsindex 1b0a23f3d6..2711a53c5c 100644--- a/packages/lambda/src/cli/commands/quotas/increase.ts+++ b/packages/lambda/src/cli/commands/quotas/increase.ts@@ -5,10 +5,13 @@ import {RequestServiceQuotaIncreaseCommand,} from '@aws-sdk/client-service-quotas';import {AwsRegion, LambdaClientInternals} from '@remotion/lambda-client';+import {+ BINARY_NAME,+ LAMBDA_CONCURRENCY_LIMIT_QUOTA,+} from '@remotion/lambda-client/constants';import type {LogLevel, LogOptions} from '@remotion/renderer';import {exit} from 'node:process';import {QUOTAS_COMMAND} from '.';-import {BINARY_NAME, LAMBDA_CONCURRENCY_LIMIT_QUOTA} from '../../../defaults';import {forceFlagProvided} from '../../args';import {getAwsRegion} from '../../get-aws-region';import {confirmCli} from '../../helpers/confirm';diff --git a/packages/lambda/src/cli/commands/quotas/index.ts b/packages/lambda/src/cli/commands/quotas/index.tsindex 4df6c33659..457c3efbf5 100644--- a/packages/lambda/src/cli/commands/quotas/index.ts+++ b/packages/lambda/src/cli/commands/quotas/index.ts@@ -1,6 +1,6 @@import {CliInternals} from '@remotion/cli';+import {BINARY_NAME} from '@remotion/lambda-client/constants';import type {LogLevel} from '@remotion/renderer';-import {BINARY_NAME} from '../../../defaults';import {INCREASE_SUBCOMMAND, quotasIncreaseCommand} from './increase';import {quotasListCommand} from './list';export const QUOTAS_COMMAND = 'quotas';diff --git a/packages/lambda/src/cli/commands/quotas/list.ts b/packages/lambda/src/cli/commands/quotas/list.tsindex 4a0d2c48f0..df6319e651 100644--- a/packages/lambda/src/cli/commands/quotas/list.ts+++ b/packages/lambda/src/cli/commands/quotas/list.ts@@ -5,9 +5,12 @@ import {} from '@aws-sdk/client-service-quotas';import {CliInternals} from '@remotion/cli';import {LambdaClientInternals} from '@remotion/lambda-client';+import {+ BINARY_NAME,+ LAMBDA_CONCURRENCY_LIMIT_QUOTA,+} from '@remotion/lambda-client/constants';import type {LogLevel} from '@remotion/renderer';import {QUOTAS_COMMAND} from '.';-import {BINARY_NAME, LAMBDA_CONCURRENCY_LIMIT_QUOTA} from '../../../defaults';import {getAwsRegion} from '../../get-aws-region';import {Log} from '../../log';import {INCREASE_SUBCOMMAND} from './increase';diff --git a/packages/lambda/src/cli/commands/render/progress.ts b/packages/lambda/src/cli/commands/render/progress.tsindex 4387a4e206..a8f8159816 100644--- a/packages/lambda/src/cli/commands/render/progress.ts+++ b/packages/lambda/src/cli/commands/render/progress.ts@@ -1,9 +1,9 @@import {CliInternals} from '@remotion/cli';+import type {RenderProgress} from '@remotion/lambda-client/constants';import {RenderInternals} from '@remotion/renderer';import type {CloudProvider, ReceivedArtifact} from '@remotion/serverless';import {truthy} from '@remotion/serverless';import {NoReactInternals} from 'remotion/no-react';-import type {RenderProgress} from '../../../defaults';type LambdaInvokeProgress = {totalLambdas: number | null;diff --git a/packages/lambda/src/cli/commands/render/render.ts b/packages/lambda/src/cli/commands/render/render.tsindex 1329af8ecf..8463e25aa0 100644--- a/packages/lambda/src/cli/commands/render/render.ts+++ b/packages/lambda/src/cli/commands/render/render.ts@@ -12,17 +12,17 @@ import {getRenderProgress,LambdaClientInternals,} from '@remotion/lambda-client';+import {+ BINARY_NAME,+ DEFAULT_MAX_RETRIES,+ DEFAULT_OUTPUT_PRIVACY,+} from '@remotion/lambda-client/constants';import type {EnhancedErrorInfo, ProviderSpecifics} from '@remotion/serverless';import {validateFramesPerFunction,validatePrivacy,type ServerlessCodec,} from '@remotion/serverless';-import {- BINARY_NAME,- DEFAULT_MAX_RETRIES,- DEFAULT_OUTPUT_PRIVACY,-} from '../../../defaults';import {sleep} from '../../../shared/sleep';import {validateMaxRetries} from '../../../shared/validate-retries';import {parsedLambdaCli} from '../../args';diff --git a/packages/lambda/src/cli/commands/sites/create.ts b/packages/lambda/src/cli/commands/sites/create.tsindex 424d71df63..1566655bda 100644--- a/packages/lambda/src/cli/commands/sites/create.ts+++ b/packages/lambda/src/cli/commands/sites/create.ts@@ -4,10 +4,10 @@ import type {LogLevel} from '@remotion/renderer';import {BrowserSafeApis} from '@remotion/renderer/client';import {AwsProvider} from '@remotion/lambda-client';+import {BINARY_NAME} from '@remotion/lambda-client/constants';import type {ProviderSpecifics} from '@remotion/serverless';import {internalGetOrCreateBucket, type Privacy} from '@remotion/serverless';import {NoReactInternals} from 'remotion/no-react';-import {BINARY_NAME} from '../../../defaults';import {awsFullClientSpecifics} from '../../../functions/full-client-implementation';import {LambdaInternals} from '../../../internals';import {validateSiteName} from '../../../shared/validate-site-name';diff --git a/packages/lambda/src/cli/commands/sites/index.ts b/packages/lambda/src/cli/commands/sites/index.tsindex e487e20da6..dccf9648ff 100644--- a/packages/lambda/src/cli/commands/sites/index.ts+++ b/packages/lambda/src/cli/commands/sites/index.ts@@ -1,8 +1,8 @@import {CliInternals} from '@remotion/cli';import {AwsProvider} from '@remotion/lambda-client';+import {BINARY_NAME} from '@remotion/lambda-client/constants';import type {LogLevel} from '@remotion/renderer';import type {ProviderSpecifics} from '@remotion/serverless';-import {BINARY_NAME} from '../../../defaults';import {quit} from '../../helpers/quit';import {SITES_CREATE_SUBCOMMAND, sitesCreateSubcommand} from './create';import {SITES_LS_SUBCOMMAND, sitesLsSubcommand} from './ls';diff --git a/packages/lambda/src/cli/commands/still.ts b/packages/lambda/src/cli/commands/still.tsindex e18291a40e..b952a3d061 100644--- a/packages/lambda/src/cli/commands/still.ts+++ b/packages/lambda/src/cli/commands/still.ts@@ -5,6 +5,11 @@ import {LambdaClientInternals,renderStillOnLambda,} from '@remotion/lambda-client';+import {+ BINARY_NAME,+ DEFAULT_MAX_RETRIES,+ DEFAULT_OUTPUT_PRIVACY,+} from '@remotion/lambda-client/constants';import type {ChromiumOptions, LogLevel} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';import {BrowserSafeApis} from '@remotion/renderer/client';@@ -13,11 +18,6 @@ import {validatePrivacy} from '@remotion/serverless';import path from 'path';import {NoReactInternals} from 'remotion/no-react';import {internalDownloadMedia} from '../../api/download-media';-import {- BINARY_NAME,- DEFAULT_MAX_RETRIES,- DEFAULT_OUTPUT_PRIVACY,-} from '../../defaults';import {validateMaxRetries} from '../../shared/validate-retries';import {parsedLambdaCli} from '../args';import {getAwsRegion} from '../get-aws-region';diff --git a/packages/lambda/src/cli/get-aws-region.ts b/packages/lambda/src/cli/get-aws-region.tsindex 17b7b18f1f..2d3c7488d1 100644--- a/packages/lambda/src/cli/get-aws-region.ts+++ b/packages/lambda/src/cli/get-aws-region.ts@@ -1,5 +1,5 @@import {AwsRegion, LambdaClientInternals} from '@remotion/lambda-client';-import {DEFAULT_REGION} from '../defaults';+import {DEFAULT_REGION} from '@remotion/lambda-client/constants';import {parsedLambdaCli} from './args';export const getAwsRegion = (): AwsRegion => {diff --git a/packages/lambda/src/cli/help.ts b/packages/lambda/src/cli/help.tsindex 8415b04bdf..c6f26015ef 100644--- a/packages/lambda/src/cli/help.ts+++ b/packages/lambda/src/cli/help.ts@@ -1,6 +1,6 @@import {CliInternals} from '@remotion/cli';+import {BINARY_NAME} from '@remotion/lambda-client/constants';import type {LogLevel} from '@remotion/renderer';-import {BINARY_NAME} from '../defaults';import {COMPOSITIONS_COMMAND} from './commands/compositions';import {FUNCTIONS_COMMAND} from './commands/functions';import {POLICIES_COMMAND} from './commands/policies/policies';diff --git a/packages/lambda/src/cli/helpers/find-function-name.ts b/packages/lambda/src/cli/helpers/find-function-name.tsindex e4d4513222..813a54f0a3 100644--- a/packages/lambda/src/cli/helpers/find-function-name.ts+++ b/packages/lambda/src/cli/helpers/find-function-name.ts@@ -1,8 +1,8 @@import {AwsProvider, LambdaClientInternals} from '@remotion/lambda-client';+import {BINARY_NAME} from '@remotion/lambda-client/constants';import type {LogLevel, LogOptions} from '@remotion/renderer';import {ProviderSpecifics} from '@remotion/serverless';import {VERSION} from 'remotion/version';-import {BINARY_NAME} from '../../defaults';import {parsedLambdaCli} from '../args';import {FUNCTIONS_COMMAND} from '../commands/functions';import {FUNCTIONS_DEPLOY_SUBCOMMAND} from '../commands/functions/deploy';diff --git a/packages/lambda/src/cli/index.ts b/packages/lambda/src/cli/index.tsindex d82d891a26..f3807da73a 100644--- a/packages/lambda/src/cli/index.ts+++ b/packages/lambda/src/cli/index.ts@@ -1,5 +1,6 @@import {CliInternals} from '@remotion/cli';import {AwsProvider, LambdaClientInternals} from '@remotion/lambda-client';+import {BINARY_NAME} from '@remotion/lambda-client/constants';import type {LogLevel} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';import {@@ -8,7 +9,6 @@ import {type ProviderSpecifics,} from '@remotion/serverless';import {ROLE_NAME} from '../api/iam-validation/suggested-policy';-import {BINARY_NAME} from '../defaults';import {awsFullClientSpecifics} from '../functions/full-client-implementation';import {parsedLambdaCli} from './args';import {diff --git a/packages/lambda/src/defaults.ts b/packages/lambda/src/defaults.tsdeleted file mode 100644index 9244e09e07..0000000000--- a/packages/lambda/src/defaults.ts+++ /dev/null@@ -1 +0,0 @@-export * from '@remotion/lambda-client/constants';diff --git a/packages/lambda/src/policies.ts b/packages/lambda/src/policies.tsnew file mode 100644index 0000000000..cf44f6c33b--- /dev/null+++ b/packages/lambda/src/policies.ts@@ -0,0 +1 @@+export * from './api/iam-validation/suggested-policy';diff --git a/packages/lambda/src/shared/function-zip-path.ts b/packages/lambda/src/shared/function-zip-path.tsindex 10d188d690..4a14f9add9 100644--- a/packages/lambda/src/shared/function-zip-path.ts+++ b/packages/lambda/src/shared/function-zip-path.ts@@ -1,6 +1,5 @@-import path from 'node:path';+// Don't concatenate as we don't want Bun bundler to hardcode this-export const FUNCTION_ZIP_ARM64 = path.join(- path.resolve(__dirname, '..', '..'),- `remotionlambda-arm64.zip`,-);+const a = 'remotionlambda-arm64.zip';++export const FUNCTION_ZIP_ARM64 = require.resolve(`../../` + a);diff --git a/packages/lambda/src/shared/validate-timeout.ts b/packages/lambda/src/shared/validate-timeout.tsindex 6cab4a059a..4faef88cd4 100644--- a/packages/lambda/src/shared/validate-timeout.ts+++ b/packages/lambda/src/shared/validate-timeout.ts@@ -1,4 +1,4 @@-import {MAX_TIMEOUT, MIN_TIMEOUT} from '../defaults';+import {MAX_TIMEOUT, MIN_TIMEOUT} from '@remotion/lambda-client/constants';export const validateTimeout = (timeoutInSeconds: unknown) => {if (typeof timeoutInSeconds !== 'number') {diff --git a/packages/lambda/src/test/integration/cli.test.ts b/packages/lambda/src/test/integration/cli.test.tsindex 50c5c2a024..387b45542c 100644--- a/packages/lambda/src/test/integration/cli.test.ts+++ b/packages/lambda/src/test/integration/cli.test.ts@@ -1,12 +1,12 @@// eslint-disable-next-line no-restricted-importsimport {CliInternals} from '@remotion/cli';import {LambdaClientInternals} from '@remotion/lambda-client';-import {afterEach, beforeEach, expect, test} from 'bun:test';import {DEFAULT_EPHEMERAL_STORAGE_IN_MB,DEFAULT_MEMORY_SIZE,DEFAULT_TIMEOUT,-} from '../../defaults';+} from '@remotion/lambda-client/constants';+import {afterEach, beforeEach, expect, test} from 'bun:test';import {LambdaInternals} from '../../internals';import {mockFullClientSpecifics} from '../mock-implementation';import {mockImplementation} from '../mocks/mock-implementation';diff --git a/packages/lambda/src/test/mocks/mock-implementation.ts b/packages/lambda/src/test/mocks/mock-implementation.tsindex ec713c076b..114eb7cbaf 100644--- a/packages/lambda/src/test/mocks/mock-implementation.ts+++ b/packages/lambda/src/test/mocks/mock-implementation.ts@@ -1,10 +1,10 @@import type {AwsProvider} from '@remotion/lambda-client';import {estimatePrice, LambdaClientInternals} from '@remotion/lambda-client';+import {REMOTION_BUCKET_PREFIX} from '@remotion/lambda-client/constants';import {RenderInternals} from '@remotion/renderer';import type {ProviderSpecifics} from '@remotion/serverless';import {createReadStream, writeFileSync} from 'fs';import path from 'path';-import {REMOTION_BUCKET_PREFIX} from '../../defaults';import {getMockCallFunctionAsync,getMockCallFunctionStreaming,diff --git a/packages/renderer/bundle.ts b/packages/renderer/bundle.tsnew file mode 100644index 0000000000..32d4a7b44d--- /dev/null+++ b/packages/renderer/bundle.ts@@ -0,0 +1,27 @@+import {buildPackage} from '../.monorepo/builder';++await buildPackage({+ formats: {+ cjs: 'use-tsc',+ esm: 'build',+ },+ external: 'dependencies',+ entrypoints: [+ {+ path: 'src/index.ts',+ target: 'node',+ },+ {+ path: 'src/client.ts',+ target: 'node',+ },+ {+ path: 'src/pure.ts',+ target: 'browser',+ },+ {+ path: 'src/error-handling.ts',+ target: 'node',+ },+ ],+});diff --git a/packages/renderer/package.json b/packages/renderer/package.jsonindex 97d6097c70..d888ddb5d8 100644--- a/packages/renderer/package.json+++ b/packages/renderer/package.json@@ -12,7 +12,7 @@"formatting": "prettier src --check","lint": "eslint src","test": "bun test src",- "make": "tsc -d"+ "make": "tsc -d && bun --env-file=../.env.bundle bundle.ts"},"author": "Jonny Burger <[email protected]>","license": "SEE LICENSE IN LICENSE.md",@@ -61,5 +61,45 @@"publishConfig": {"access": "public"},- "homepage": "https://www.remotion.dev/docs/renderer"+ "homepage": "https://www.remotion.dev/docs/renderer",+ "exports": {+ "./package.json": "./package.json",+ ".": {+ "types": "./dist/index.d.ts",+ "require": "./dist/index.js",+ "module": "./dist/esm/index.mjs",+ "import": "./dist/esm/index.mjs"+ },+ "./client": {+ "types": "./dist/client.d.ts",+ "require": "./dist/client.js",+ "module": "./dist/esm/client.mjs",+ "import": "./dist/esm/client.mjs"+ },+ "./pure": {+ "types": "./dist/pure.d.ts",+ "require": "./dist/pure.js",+ "module": "./dist/esm/pure.mjs",+ "import": "./dist/esm/pure.mjs"+ },+ "./error-handling": {+ "types": "./dist/error-handling.d.ts",+ "require": "./dist/error-handling.js",+ "module": "./dist/esm/error-handling.mjs",+ "import": "./dist/esm/error-handling.mjs"+ }+ },+ "typesVersions": {+ ">=1.0": {+ "client": [+ "dist/client.d.ts"+ ],+ "pure": [+ "dist/pure.d.ts"+ ],+ "error-handling": [+ "dist/error-handling.d.ts"+ ]+ }+ }}diff --git a/packages/renderer/src/assets/download-map.ts b/packages/renderer/src/assets/download-map.tsindex 2ce1fadf18..34fa2e83c1 100644--- a/packages/renderer/src/assets/download-map.ts+++ b/packages/renderer/src/assets/download-map.ts@@ -62,7 +62,8 @@ const makeAndReturn = (dir: string, name: string) => {return p;};-const packageJsonPath = path.join(__dirname, '..', '..', 'package.json');+const dontInlineThis = 'package.json';+const packageJsonPath = require.resolve('../../' + dontInlineThis);const packageJson = fs.existsSync(packageJsonPath)? JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))