π₯ Make videos programmatically with React
add docs
Jonny Burgerc6f581ce0e0b
diff --git a/packages/docs/docs/miscellaneous/ts-aliases.md b/packages/docs/docs/miscellaneous/ts-aliases.mdnew file mode 100644index 0000000000..fe6d477edd--- /dev/null+++ b/packages/docs/docs/miscellaneous/ts-aliases.md@@ -0,0 +1,57 @@+---+title: "TypeScript aliases"+id: typescript-aliases+slug: /typescript-aliases+---++Typescript aliases are not supported by default, since the ESBuild Webpack loader we have does not support them.+You can however patch the Webpack config to make them resolve.++Assuming you have a file:++```+ βββ src/+ βββ lib/+ β βββ one.ts+ β βββ two.ts+ βββ Video.tsx+ βββ index.ts+```++and your tsconfig.json has the following `paths`:++```json+{+ "compilerOptions": {+ "paths": {+ "lib/*": ["./src/lib/*"]+ }+ }+}+```++you can add the aliases to Webpack, however you need to add each of them manually:++```ts twoslash+import path from "path";+import { Config } from "remotion";++Config.Bundling.overrideWebpackConfig((config) => {+ return {+ ...config,+ resolve: {+ ...config.resolve,+ alias: {+ ...(config.resolve?.alias ?? {}),+ lib: path.join(process.cwd(), "src", "lib"),+ },+ },+ };+});+```++Remember that in Node.JS APIs, the config file does not apply, so you need to add the Webpack override also to the [`bundle()`](/docs/bundle) and [`deploySite()`](/docs/lambda/deploysite) functions.++## See also++- [Overriding webpack config](/docs/webpack)diff --git a/packages/docs/docs/overwriting-webpack-config.md b/packages/docs/docs/overwriting-webpack-config.mdindex 49a021c8db..e6e1f57a87 100644--- a/packages/docs/docs/overwriting-webpack-config.md+++ b/packages/docs/docs/overwriting-webpack-config.md@@ -381,6 +381,10 @@ After restarting, you can import `.wasm` files using an import statement.See [Using legacy Babel transpilation](/docs/legacy-babel).+## Enable TypeScript aliases++See [TypeScript aliases](/docs/typescript-aliases).+## Customizing configuration file locationYou can pass a `--config` option to the command line to specify a custom location for your configuration file.diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex 346488408c..ff789ab8a7 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -253,6 +253,7 @@ module.exports = {"prereleases","gpu","react-18",+ "miscellaneous/typescript-aliases",],},"3-0-migration",diff --git a/packages/example/remotion.config.ts b/packages/example/remotion.config.tsindex bdc7a6221f..d894bf8eed 100644--- a/packages/example/remotion.config.ts+++ b/packages/example/remotion.config.ts@@ -1,21 +1,5 @@-import path from 'path';import {Config} from 'remotion';import {webpackOverride} from './webpack-override';Config.Output.setOverwriteOutput(true);Config.Bundling.overrideWebpackConfig(webpackOverride);-Config.Bundling.overrideWebpackConfig((config) => {- const newConfig = webpackOverride(config);- return {- ...newConfig,- resolve: {- ...newConfig.resolve,- alias: {- ...newConfig.resolve.alias,- 'lib/alias': require.resolve(- path.join(process.cwd(), 'src', 'lib', 'alias.ts')- ),- },- },- };-});diff --git a/packages/example/src/lib/index.ts b/packages/example/src/lib/index.tsnew file mode 100644index 0000000000..50dc823c67--- /dev/null+++ b/packages/example/src/lib/index.ts@@ -0,0 +1 @@+export const hi = 'index';diff --git a/packages/example/src/webpack-override.ts b/packages/example/src/webpack-override.tsindex d8dfcea8df..1c40ed5c73 100644--- a/packages/example/src/webpack-override.ts+++ b/packages/example/src/webpack-override.ts@@ -48,5 +48,12 @@ export const webpackOverride: WebpackOverrideFn = (currentConfiguration) => {},],},+ resolve: {+ ...replaced.resolve,+ alias: {+ ...replaced.resolve.alias,+ lib: path.join(process.cwd(), 'src', 'lib'),+ },+ },};};