Skip to content

🎥 Make videos programmatically with React

move render-all example to mjs and top level await

Jonny Burger6314182e5986
diff --git a/packages/docs/docs/render-all.md b/packages/docs/docs/render-all.md
index 9b37286939..77cd7e5bdd 100644
--- a/packages/docs/docs/render-all.md
+++ b/packages/docs/docs/render-all.md
@@ -34,38 +34,34 @@ This only works on UNIX-based systems (Linux, macOS) and on WSL in Windows.
You can create a script that fits you using the [Node.JS APIs](/docs/renderer). Below is an example
-```ts twoslash title="render-all.ts"
+```ts twoslash title="render-all.mjs"
import { bundle } from "@remotion/bundler";
import { getCompositions, renderMedia } from "@remotion/renderer";
+import { createRequire } from "module";
-const start = async () => {
- const bundled = await bundle({
- entryPoint: require.resolve("./src/index.ts"),
- // If you have a Webpack override, make sure to add it here
- webpackOverride: (config) => config,
- });
+const require = createRequire(import.meta.url);
+
+const bundled = await bundle({
+ entryPoint: require.resolve("./src/index.ts"),
+ // If you have a Webpack override, make sure to add it here
+ webpackOverride: (config) => config,
+});
+
+const compositions = await getCompositions(bundled);
- const compositions = await getCompositions(bundled);
-
- for (const composition of compositions) {
- console.log(`Rendering ${composition.id}...`);
- await renderMedia({
- codec: "h264",
- composition,
- serveUrl: bundled,
- outputLocation: `out/${composition.id}.mp4`,
- });
- }
-};
-
-start()
- .then(() => {
- process.exit(0);
- })
- .catch((err) => {
- console.log(err);
- process.exit(1);
+for (const composition of compositions) {
+ console.log(`Rendering ${composition.id}...`);
+ await renderMedia({
+ codec: "h264",
+ composition,
+ serveUrl: bundled,
+ outputLocation: `out/${composition.id}.mp4`,
});
+}
+```
+
+```bash title="Execute"
+node render-all.mjs
```
## See also