🎥 Make videos programmatically with React
ESM
Jonny Burgerc7a3e5b929d1
diff --git a/packages/docs/docs/config.md b/packages/docs/docs/config.mdindex 5d77532e6a..25992783c3 100644--- a/packages/docs/docs/config.md+++ b/packages/docs/docs/config.md@@ -25,26 +25,6 @@ Config.setPixelFormat("yuv444p");Config.setCodec("h265");```-## Old config file format--In v3.3.39, a new config file format was introduced which flattens the options so they can more easily be discovered using TypeScript autocompletion.--Previously, each config option was two levels deep:--```ts title="remotion.config.ts"-Config.Bundling.setCachingEnabled(false);-```--From v3.3.39 on, all options can be accessed directly from the `Config` object.--```ts twoslash title="remotion.config.ts"-import { Config } from "@remotion/cli/config";-// ---cut----Config.setCachingEnabled(false);-```--The old way is deprecated, but will work for the foreseeable future.-## overrideWebpackConfig()<AvailableFrom v="1.1.0" />Allows you to insert your custom Webpack config. [See the page about custom Webpack configs](/docs/webpack) for more information.@@ -867,6 +847,45 @@ Config.setPort(3003);The [command line flag](/docs/cli/render#--port) `--port` will take precedence over this option. If set on `npx remotion studio`, it will set the Studio port, otherwise the renderer port.+## Importing ES Modules++The [config file](/docs/config) gets executed in a CommonJS environment. If you want to import ES modules to override the Webpack config, you can pass an async function to `Config.overrideWebpackConfig()`:++```ts twoslash title="remotion.config.ts"+// @filename: src/enable-sass.ts+import { WebpackOverrideFn } from "@remotion/bundler";+export const enableSass: WebpackOverrideFn = (c) => c;++// @filename: remotion.config.ts+// ---cut---+import { Config } from "@remotion/cli/config";++Config.overrideWebpackConfig(async (currentConfiguration) => {+ const { enableSass } = await import("./src/enable-sass");+ return enableSass(currentConfiguration);+});+```++## Old config file format++In v3.3.39, a new config file format was introduced which flattens the options so they can more easily be discovered using TypeScript autocompletion.++Previously, each config option was two levels deep:++```ts title="remotion.config.ts"+Config.Bundling.setCachingEnabled(false);+```++From v3.3.39 on, all options can be accessed directly from the `Config` object.++```ts twoslash title="remotion.config.ts"+import { Config } from "@remotion/cli/config";+// ---cut---+Config.setCachingEnabled(false);+```++The old way is deprecated, but will work for the foreseeable future.+## See also- [Encoding guide](/docs/encoding)diff --git a/packages/docs/docs/overwriting-webpack-config.md b/packages/docs/docs/overwriting-webpack-config.mdxsimilarity index 92%rename from packages/docs/docs/overwriting-webpack-config.mdrename to packages/docs/docs/overwriting-webpack-config.mdxindex 6def9c4c92..0f81d99b79 100644--- a/packages/docs/docs/overwriting-webpack-config.md+++ b/packages/docs/docs/overwriting-webpack-config.mdx@@ -6,7 +6,7 @@ crumb: "How To"---import Tabs from "@theme/Tabs";-import TabItem from '@theme/TabItem';+import TabItem from "@theme/TabItem";Remotion ships with [it's own Webpack configuration](https://github.com/remotion-dev/remotion/blob/main/packages/bundler/src/webpack-config.ts).@@ -14,7 +14,7 @@ You can override it reducer-style by creating a function that takes the previous## When rendering using the command line-In your `remotion.config.ts` file, you can call `Config.Bundler.overrideWebpackConfig()` from `remotion`.+In your [`remotion.config.ts`](/docs/config) file, you can call [`Config.overrideWebpackConfig()`](/docs/config#overridewebpackconfig) from `@remotion/cli/config`.```ts twoslash title="remotion.config.ts"import { Config } from "@remotion/cli/config";@@ -421,6 +421,25 @@ See [TypeScript aliases](/docs/typescript-aliases).You can pass a `--config` option to the command line to specify a custom location for your configuration file.+## Importing ES Modules in remotion.config.ts<AvailableFrom v="4.0.117"/>++The [config file](/docs/config) gets executed in a CommonJS environment. If you want to import ES modules, you can pass an async function to `Config.overrideWebpackConfig`:++```ts twoslash title="remotion.config.ts"+// @filename: src/enable-sass.ts+import { WebpackOverrideFn } from "@remotion/bundler";+export const enableSass: WebpackOverrideFn = (c) => c;++// @filename: remotion.config.ts+// ---cut---+import { Config } from "@remotion/cli/config";++Config.overrideWebpackConfig(async (currentConfiguration) => {+ const { enableSass } = await import("./src/enable-sass");+ return enableSass(currentConfiguration);+});+```+## See also- [Configuration file](/docs/config)