Skip to content

🎥 Make videos programmatically with React

Revert "Merge pull request #11255 from remotion-dev/codex/fix-rspack-optional-bundle"

JonnyBurgere2a6fe3621ac
diff --git a/packages/bundler/src/bundle.ts b/packages/bundler/src/bundle.ts
index 78684132fd..90df81a276 100644
--- a/packages/bundler/src/bundle.ts
+++ b/packages/bundler/src/bundle.ts
@@ -367,13 +367,6 @@ export const internalBundle = async (
}
}
- const bundleOutput = path.join(outDir, NoReactInternals.bundleName);
- if (!fs.existsSync(bundleOutput)) {
- throw new Error(
- `The bundler completed without emitting ${NoReactInternals.bundleName}.`,
- );
- }
-
const publicPath = getBundlePublicPath(actualArgs.publicPath);
const staticHash = getBundleStaticHash(publicPath);
diff --git a/packages/bundler/src/rspack-config.ts b/packages/bundler/src/rspack-config.ts
index e323a4aa84..eb775fe58b 100644
--- a/packages/bundler/src/rspack-config.ts
+++ b/packages/bundler/src/rspack-config.ts
@@ -83,12 +83,6 @@ export const rspackConfig = async ({
const sharedBaseConfig = getBaseConfig(environment, poll);
const baseConfig = {
...sharedBaseConfig,
- optimization: {
- ...sharedBaseConfig.optimization,
- // The optional dependency plugin removes expected resolution errors after
- // compilation. Rspack must emit their throwing fallback chunks first.
- emitOnErrors: true,
- },
experiments: {
...sharedBaseConfig.experiments,
...(environment === 'development'
diff --git a/packages/bundler/src/test/rspack-optional-dependencies.test.ts b/packages/bundler/src/test/rspack-optional-dependencies.test.ts
deleted file mode 100644
index 9b9255eb9d..0000000000
--- a/packages/bundler/src/test/rspack-optional-dependencies.test.ts
+++ /dev/null
@@ -1,119 +0,0 @@
-import {expect, test} from 'bun:test';
-import {
- existsSync,
- mkdirSync,
- mkdtempSync,
- readFileSync,
- rmSync,
- writeFileSync,
-} from 'node:fs';
-import {tmpdir} from 'node:os';
-import path from 'node:path';
-import {bundle} from '../bundle';
-
-test(
- 'Rspack emits a bundle when optional Studio dependencies are missing',
- async () => {
- const fixtureDirectory = mkdtempSync(
- path.join(tmpdir(), 'remotion-rspack-optional-dependency-'),
- );
- const studioDirectory = path.join(
- fixtureDirectory,
- 'node_modules',
- '@remotion',
- 'studio',
- );
- const entryPoint = path.join(studioDirectory, 'entry.js');
- const outputDirectory = path.join(fixtureDirectory, 'build');
- mkdirSync(studioDirectory, {recursive: true});
- writeFileSync(
- entryPoint,
- "void import('@remotion/whisper-webgpu');\n",
- 'utf8',
- );
-
- try {
- const output = await bundle({
- enableCaching: false,
- entryPoint,
- ignoreRegisterRootWarning: true,
- outDir: outputDirectory,
- rootDir: fixtureDirectory,
- rspack: true,
- });
-
- expect(output).toBe(outputDirectory);
- const bundlePath = path.join(output, 'bundle.js');
- expect(existsSync(bundlePath)).toBe(true);
- expect(readFileSync(bundlePath, 'utf8').length).toBeGreaterThan(0);
- } finally {
- rmSync(fixtureDirectory, {recursive: true, force: true});
- }
- },
- {timeout: 60_000},
-);
-
-test(
- 'bundle fails if Rspack does not emit bundle.js',
- async () => {
- const fixtureDirectory = mkdtempSync(
- path.join(tmpdir(), 'remotion-rspack-missing-output-'),
- );
- const entryPoint = path.join(fixtureDirectory, 'entry.js');
- writeFileSync(entryPoint, 'globalThis.remotion_entry = true;\n', 'utf8');
-
- try {
- await expect(
- bundle({
- enableCaching: false,
- entryPoint,
- ignoreRegisterRootWarning: true,
- outDir: path.join(fixtureDirectory, 'build'),
- rootDir: fixtureDirectory,
- rspack: true,
- rspackOverride: (configuration) => ({
- ...configuration,
- output: {
- ...configuration.output,
- filename: 'unexpected.js',
- },
- }),
- }),
- ).rejects.toThrow('The bundler completed without emitting bundle.js.');
- } finally {
- rmSync(fixtureDirectory, {recursive: true, force: true});
- }
- },
- {timeout: 60_000},
-);
-
-test(
- 'Rspack still fails for missing user dependencies',
- async () => {
- const fixtureDirectory = mkdtempSync(
- path.join(tmpdir(), 'remotion-rspack-missing-user-dependency-'),
- );
- const entryPoint = path.join(fixtureDirectory, 'entry.js');
- writeFileSync(
- entryPoint,
- "import 'definitely-not-an-installed-package';\n",
- 'utf8',
- );
-
- try {
- await expect(
- bundle({
- enableCaching: false,
- entryPoint,
- ignoreRegisterRootWarning: true,
- outDir: path.join(fixtureDirectory, 'build'),
- rootDir: fixtureDirectory,
- rspack: true,
- }),
- ).rejects.toThrow("Can't resolve 'definitely-not-an-installed-package'");
- } finally {
- rmSync(fixtureDirectory, {recursive: true, force: true});
- }
- },
- {timeout: 60_000},
-);