🎥 Make videos programmatically with React
make mac universal build work
Igor Samokhovets469cacb3cb8f
diff --git a/packages/template-electron/forge.config.ts b/packages/template-electron/forge.config.tsindex 3e70cd7e75..55c4ce5397 100644--- a/packages/template-electron/forge.config.ts+++ b/packages/template-electron/forge.config.ts@@ -4,11 +4,61 @@ import {VitePlugin} from "@electron-forge/plugin-vite";import {getCompositorPackage} from "./src/compositor-package";import {bundleRemotionProject, getPrebuiltRemotionBundlePath} from "./src/remotion-bundle";+const DARWIN_COMPOSITOR_PACKAGES = [+ "@remotion/compositor-darwin-x64",+ "@remotion/compositor-darwin-arm64",+];++const DARWIN_UNIVERSAL_X64_ARCH_FILES =+ "Contents/Resources/app.asar.unpacked/node_modules/@remotion/compositor-darwin-*/**";++function getCompositorPackagesForPackaging({+ arch,+ platform,+}: {+ arch: string;+ platform: string;+}): string[] {+ if (platform === "darwin") {+ return DARWIN_COMPOSITOR_PACKAGES;+ }++ return [getCompositorPackage({arch, platform})];+}++async function stageCompositorPackage({+ buildPath,+ compositorPackage,+}: {+ buildPath: string;+ compositorPackage: string;+}): Promise<void> {+ const compositorPackageJson = require.resolve(`${compositorPackage}/package.json`, {+ paths: [process.cwd()],+ });++ const compositorSource = path.dirname(compositorPackageJson);++ const compositorDestination = path.join(+ buildPath,+ "node_modules",+ compositorPackage,+ );++ await mkdir(path.dirname(compositorDestination), {recursive: true});+ await cp(compositorSource, compositorDestination, {recursive: true});+}+const config = {packagerConfig: {asar: {unpackDir: "node_modules/@remotion/compositor-*",},+ osxUniversal: {+ // These compositor binaries are already architecture-specific and should not be+ // merged with lipo during universal packaging.+ x64ArchFiles: DARWIN_UNIVERSAL_X64_ARCH_FILES,+ },},rebuildConfig: {},hooks: {@@ -25,23 +75,18 @@ const config = {});// Electron Forge's Vite packaging does not materialize this optional runtime binary- // into the packaged app automatically, so stage the selected compositor package explicitly.- const compositorPackage = getCompositorPackage({+ // into the packaged app automatically, so stage the required compositor packages explicitly.+ const compositorPackages = getCompositorPackagesForPackaging({arch,platform,});- const compositorPackageJson = require.resolve(`${compositorPackage}/package.json`, {- paths: [process.cwd()],- });- const compositorSource = path.dirname(compositorPackageJson);- const compositorDestination = path.join(- buildPath,- "node_modules",- compositorPackage,- );- await mkdir(path.dirname(compositorDestination), {recursive: true});- await cp(compositorSource, compositorDestination, {recursive: true});+ for (const compositorPackage of compositorPackages) {+ await stageCompositorPackage({+ buildPath,+ compositorPackage,+ });+ }},},