remotion-dev/remotion · error · Error
Detected Vite pre-bundling, which will break the worker. Ple
Error message
Detected Vite pre-bundling, which will break the worker.
Please add the following to your vite.config.js:
optimizeDeps: {
exclude: ["@remotion/media-parser/worker"]
} What it means
Thrown by parseMediaOnWebWorker when import.meta.url contains '.vite/deps', indicating Vite pre-bundled the worker entry. Vite's dependency pre-bundling breaks worker instantiation because it rewrites module URLs and the new URL('./worker-web-entry.mjs', import.meta.url) pattern no longer resolves to a servable worker script.
Source
Thrown at packages/media-parser/src/worker.module.ts:34
F extends Options<ParseMediaFields>,
>(
params: ParseMediaOnWorkerOptions<F>,
) => {
if (typeof Worker === 'undefined') {
throw new Error(
'"Worker" is not available. Cannot call parseMediaOnWebWorker()',
);
}
if (import.meta.url.includes('.vite/deps')) {
const err = [
'Detected Vite pre-bundling, which will break the worker.',
'Please add the following to your vite.config.js:',
' optimizeDeps: {',
' exclude: ["@remotion/media-parser/worker"]',
' }',
].join('\n');
throw new Error(err);
}
const worker = new Worker(new URL('./worker-web-entry.mjs', import.meta.url));
return parseMediaOnWorkerImplementation(
params,
worker,
'parseMediaOnWebWorker',
);
};
View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Add optimizeDeps.exclude: ['@remotion/media-parser/worker'] to vite.config as the error message instructs.
- If the error persists, also exclude the package from build.rollupOptions or use the in-process parseMedia instead.
- Restart the Vite dev server after editing vite.config so optimizeDeps cache is rebuilt.
Example fix
// before - vite.config.js
export default { plugins: [react()] };
// after
export default {
plugins: [react()],
optimizeDeps: { exclude: ['@remotion/media-parser/worker'] },
}; Defensive patterns
Strategy: validation
Validate before calling
// vite.config.js
export default {
optimizeDeps: { exclude: ['@remotion/media-parser/worker'] },
}; Try / catch
try { await parseMediaOnWebWorker(opts); } catch (e) { if (/Vite pre-bundling/.test(String((e as Error).message))) { console.error('Add optimizeDeps.exclude for @remotion/media-parser/worker, then restart Vite'); } throw e; } Prevention
- Add optimizeDeps.exclude for @remotion/media-parser/worker in every Vite project using it.
- Restart the Vite dev server after editing optimizeDeps.
- Keep a project template config snippet for this exclusion.
When it happens
Trigger: Using parseMediaOnWebWorker inside a Vite-powered app (Vite dev server or build) without excluding @remotion/media-parser/worker from optimizeDeps. Vite pre-bundles the package, the worker URL is rewritten, and the guard trips to fail fast rather than producing a broken worker.
Common situations: New Vite project importing the media-parser web worker. Upgrading Vite and hitting stricter pre-bundling. Copying a snippet from a non-Vite project into a Vite app without adjusting the config.
Related errors
- The public directory was specified as "${p}", which is the r
- The public directory was specified as "${p}", and while this
- The public directory was specified as "${p}", but this folde
- `reader` should not be provided to `${apiName}`. If you want
- "Worker" is not available. Cannot call parseMediaOnServerWor
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/473561528c2dff32.
Report an issue: GitHub.