{"record":{"id":"b5a283f94e799788","repo":"remotion-dev/remotion","slug":"the-browser-studio-bootstrap-must-not-bundle-trans","errorCode":null,"errorMessage":"The Browser Studio bootstrap must not bundle Transformers.js. Keep it in the lazy Transformers entry.","messagePattern":"The Browser Studio bootstrap must not bundle Transformers\\.js\\. Keep it in the lazy Transformers entry\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/browser-studio/bundle.ts","lineNumber":110,"sourceCode":"if (!output.success) {\n\tconsole.log(output.logs.join('\\n'));\n\tprocess.exit(1);\n}\n\nconst externalVersionSensitiveImport =\n\t/^[^'\"\\n]*\\bfrom\\s*[\"']@remotion\\/(?:player|studio-shared|timeline-utils)[\"'];?\\s*$|^\\s*import\\s*[\"']@remotion\\/(?:player|studio-shared|timeline-utils)[\"'];?\\s*$/m;\n\nfor (const file of [\n\t...output.outputs,\n\t...vendorOutput.outputs,\n\t...transformersOutput.outputs,\n]) {\n\tconst str = await file.text();\n\tif (\n\t\t!file.path.includes('browser-studio-transformers-entry') &&\n\t\t(str.includes('onnxruntime-web') || str.includes('transformers.web.js'))\n\t) {\n\t\tthrow new Error(\n\t\t\t'The Browser Studio bootstrap must not bundle Transformers.js. Keep it in the lazy Transformers entry.',\n\t\t);\n\t}\n\n\tif (\n\t\tpath.basename(file.path) === 'browser-studio-vendor-entry.mjs' &&\n\t\texternalVersionSensitiveImport.test(str)\n\t) {\n\t\tthrow new Error(\n\t\t\t'Browser Studio must bundle version-sensitive workspace packages into its vendor entry so it cannot link against an incompatible published version.',\n\t\t);\n\t}\n\n\tconst out = path.join('dist', 'esm', file.path);\n\n\tawait Bun.write(out, str);\n}\n","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/remotion-dev/remotion/blob/b2f4e34732f3c6c222ea029413e22dc402218cd7/packages/browser-studio/bundle.ts#L92-L128","documentation":"After building the Browser Studio bootstrap, the script scans bundle outputs for forbidden strings ('onnxruntime-web' or 'transformers.web.js'). If any file other than the dedicated lazy transformers entry references them, it means Transformers.js was accidentally bundled into the main bootstrap. This is a deliberate architecture guard to keep the bootstrap small and load the heavy ML runtime lazily.","triggerScenarios":"Adding an import of @remotion/browser-studio transformers code, onnxruntime-web, or Transformers.js to a module reachable from the bootstrap entrypoint; moving transformers-dependent code out of browser-studio-transformers-entry.ts; changing the exclusion check file name so the transformers entry itself is no longer skipped.","commonSituations":"Refactoring imports so transformers utilities get pulled into the main chunk; adding a dependency that statically imports onnxruntime-web; renaming browser-studio-transformers-entry.ts without updating the guard.","solutions":["Move any Transformers.js / onnxruntime-web imports into src/browser-studio-transformers-entry.ts so they stay in the lazy entry","Check the bootstrap import graph (e.g. with a bundler analyzer) and break the dependency that pulls transformers into the main chunk","Use dynamic import() for transformers functionality in bootstrap code","If the transformers entry file was renamed, update the file.path.includes('browser-studio-transformers-entry') exclusion"],"exampleFix":"// before\nimport {transformers} from 'onnxruntime-web';\nexport const runTransformers = () => transformers();\n// after\nexport const runTransformers = async () => {\n\tconst mod = await import('./browser-studio-transformers-entry');\n\treturn mod.runTransformers();\n};","handlingStrategy":"validation","validationCode":"// pre-commit check that the bootstrap has no transformers references:\nconst offender = outputs.find((f) =>\n\t!f.path.includes('browser-studio-transformers-entry') &&\n\t(f.text().includes('onnxruntime-web') || f.text().includes('transformers.web.js')));\nif (offender) throw new Error(offender.path);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only import Transformers.js / onnxruntime-web from browser-studio-transformers-entry.ts","Use dynamic import() for heavy ML dependencies","Review the bundle graph after adding any dependency to browser-studio","Never rename the transformers entry without updating the guard"],"tags":["bundler","architecture","lazy-loading"],"backgroundTag":"internal-invariant-violation","analyzedSha":"b2f4e34732f3c6c222ea029413e22dc402218cd7","analyzedAt":"2026-09-09T13:27:51.281Z","contentChangedAt":"2026-09-09T13:27:51.281Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}