Skip to content

🎥 Make videos programmatically with React

`@remotion/bundler`: ESBuild loader picks up right tsconfig.json

Jonny Burger8e7c56766c93
diff --git a/packages/bundler/src/esbuild-loader/index.ts b/packages/bundler/src/esbuild-loader/index.ts
index fcc79a4b45..4d4172cb69 100644
--- a/packages/bundler/src/esbuild-loader/index.ts
+++ b/packages/bundler/src/esbuild-loader/index.ts
@@ -19,11 +19,10 @@ async function ESBuildLoader(
source: string,
): Promise<void> {
const done = this.async();
- this.getOptions();
const options: LoaderOptions = this.getOptions();
- const {implementation, ...esbuildTransformOptions} = options;
+ const {implementation, remotionRoot, ...esbuildTransformOptions} = options;
- const tsConfigPath = path.join(this.context, 'tsconfig.json');
+ const tsConfigPath = path.join(remotionRoot, 'tsconfig.json');
if (implementation && typeof implementation.transform !== 'function') {
done(
diff --git a/packages/bundler/src/esbuild-loader/interfaces.ts b/packages/bundler/src/esbuild-loader/interfaces.ts
index d3e64f5a50..2d29d39165 100644
--- a/packages/bundler/src/esbuild-loader/interfaces.ts
+++ b/packages/bundler/src/esbuild-loader/interfaces.ts
@@ -15,4 +15,5 @@ export type LoaderOptions = Except<
'sourcemap' | 'sourcefile'
> & {
implementation: Implementation;
+ remotionRoot: string;
};
diff --git a/packages/bundler/src/webpack-config.ts b/packages/bundler/src/webpack-config.ts
index 0ad90d1667..033a15675a 100644
--- a/packages/bundler/src/webpack-config.ts
+++ b/packages/bundler/src/webpack-config.ts
@@ -33,12 +33,6 @@ const shouldUseReactDomClient = NoReactInternals.ENABLE_V5_BREAKING_CHANGES
? true
: parseInt(reactDomVersion, 10) >= 18;
-const esbuildLoaderOptions: LoaderOptions = {
- target: 'chrome85',
- loader: 'tsx',
- implementation: esbuild,
-};
-
type Truthy<T> = T extends false | '' | 0 | null | undefined ? never : T;
function truthy<T>(value: T): value is Truthy<T> {
@@ -72,6 +66,13 @@ export const webpackConfig = async ({
remotionRoot: string;
poll: number | null;
}): Promise<[string, WebpackConfiguration]> => {
+ const esbuildLoaderOptions: LoaderOptions = {
+ target: 'chrome85',
+ loader: 'tsx',
+ implementation: esbuild,
+ remotionRoot,
+ };
+
let lastProgress = 0;
const isBun = typeof Bun !== 'undefined';