🎥 Make videos programmatically with React
bundling bundle
Jonny Burger6f0a6a64e4db
diff --git a/packages/docs/docs/bundle.md b/packages/docs/docs/bundle.mdindex 4158948bd5..9449f18b73 100644--- a/packages/docs/docs/bundle.md+++ b/packages/docs/docs/bundle.md@@ -9,7 +9,12 @@ _Part of the `@remotion/bundler` package._Bundles a Remotion project using Webpack and prepares it for rendering using [`renderMedia()`](/docs/renderer/render-media).-```ts+You only need to call this function when the source code changes. You can render multiple videos from the same bundle and parametrize them using [input props](/docs/passing-props).++Calling `bundle()` for every video that you render is an anti-pattern.+`bundle()` cannot be called in a serverless function, see: [Calling bundle() in bundled code](/docs/troubleshooting/bundling-bundle).++```ts title="Function signature"const bundle: (options?: {entryPoint: string;onProgress?: (progress: number) => void;@@ -116,7 +121,7 @@ const bundle: (publicPath?: string;rootDir?: string;publicDir?: string | null;- }+ },) => Promise<string>;```@@ -141,3 +146,4 @@ A promise which will resolve into a `string` specifying the output directory.- [getCompositions()](/docs/renderer/get-compositions)- [renderMedia()](/docs/renderer/render-media)- [stitchFramesToVideo()](/docs/renderer/stitch-frames-to-video)+- [Calling bundle() in bundled code](/docs/troubleshooting/bundling-bundle)diff --git a/packages/docs/docs/troubleshooting/bundling-bundle.md b/packages/docs/docs/troubleshooting/bundling-bundle.mdnew file mode 100644index 0000000000..65c72e5b52--- /dev/null+++ b/packages/docs/docs/troubleshooting/bundling-bundle.md@@ -0,0 +1,46 @@+---+sidebar_label: Calling bundle() in bundled code+title: Calling bundle() in bundled code+crumb: "FAQ"+---++If you receive the following error:++```+ ⨯ ./node_modules/@remotion/compositor-darwin-arm64/compositor+Module parse failed: Unexpected character '�' (1:0)+You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders+(Source code omitted for this binary file)+```++it means that the [`bundle()`](/docs/bundle) function is being bundled itself for example by Webpack or ESBuild.++This occurs for example if [`bundle()`](/docs/bundle) or [`deploySite()`](/docs/lambda/deploysite) is being called in a Next.js serverless function.++To bundle the `bundle()` function, Webpack needs specific configuration, which is missing.++However, we don't recommend that you call `bundle()` at runtime at all.++## What you actually want++Most likely, you don't want to bundle your video at runtime, but rather at build time.++You only need to re-bundle the video if you change the source code of it. However, this should not be necessary at runtime, as you can parametrize everything without changing the source code.++See how to parametrize the [content with input props](/docs/passing-props) as well as the [metadata of your video](/docs/dynamic-metadata).++## Recipes++**If you are using a long-running server:** we recommend to call `bundle()` once in a Node.js context and then reusing it for the lifetime of the server. See: [Rendering in Node.js](/docs/ssr-node)++**If you are rendering on Lambda**: Create a bundle and deploy it once either via [`npx remotion sites create`](/docs/lambda/cli/sites#create) or using [`deploySite()`](/docs/lambda/deploysite) in a non-bundled Node.js script and then refer to the bundle via the URL that you get back.++In both cases, do all parameterization of the video using [input props](/docs/parameterized-rendering).++## See also++- [Rendering in Node.js](/docs/ssr-node)+- [Deploying a site](/docs/lambda/deploysite)+- [Parameterized rendering](/docs/parameterized-rendering)+- [`bundle()`](/docs/bundle)+- [`deploySite()`](/docs/lambda/deploysite)diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex a6bb1270d6..b1dd11ed61 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -705,6 +705,7 @@ module.exports = {"troubleshooting/broken-fast-refresh","troubleshooting/timed-out-page-function","troubleshooting/delay-render-proxy",+ "troubleshooting/bundling-bundle",],},{@@ -780,6 +781,8 @@ module.exports = {"miscellaneous/vercel-functions","miscellaneous/render-on-edge","miscellaneous/embed-studio",+ "miscellaneous/absolute-paths",+"compare/motion-canvas",],},