🎥 Make videos programmatically with React
should not import remotion unnecessarily
Jonny Burger79a85afc7550
diff --git a/packages/cli/.eslintrc b/packages/cli/.eslintrcindex 04e68f8bda..c4f70c2065 100644--- a/packages/cli/.eslintrc+++ b/packages/cli/.eslintrc@@ -1,13 +1,21 @@{"extends": "@jonny","rules": {- "no-console": "error"+ "no-console": "error",+ "no-restricted-imports": ["error", "remotion"]},"overrides": [{"files": "./src/editor/**","rules": {- "no-console": "off"+ "no-console": "off",+ "no-restricted-imports": ["off"]+ }+ },+ {+ "files": "./src/preview-server/error-overlay/**",+ "rules": {+ "no-restricted-imports": ["off"]}}]diff --git a/packages/cli/src/code-frame.ts b/packages/cli/src/code-frame.tsindex f76c867b82..4c5428caee 100644--- a/packages/cli/src/code-frame.ts+++ b/packages/cli/src/code-frame.ts@@ -2,9 +2,9 @@ import type {ErrorWithStackFrame,SymbolicatedStackFrame,} from '@remotion/renderer';-import {Internals} from 'remotion';import {chalk} from './chalk';import {Log} from './log';+import {truthy} from './truthy';const makeFileName = (firstFrame: SymbolicatedStackFrame) => {return [@@ -14,7 +14,7 @@ const makeFileName = (firstFrame: SymbolicatedStackFrame) => {? null: firstFrame.originalColumnNumber,]- .filter(Internals.truthy)+ .filter(truthy).join(':');};@@ -57,7 +57,7 @@ const logLine = (frame: SymbolicatedStackFrame) => {Log.info(chalk.gray(['at', frame.originalFunctionName, `${chalk.blueBright(`(${fileName})`)}`]- .filter(Internals.truthy)+ .filter(truthy).join(' ')));diff --git a/packages/cli/src/preview-server/error-overlay/react-overlay/effects/map-error-to-react-stack.ts b/packages/cli/src/preview-server/error-overlay/react-overlay/effects/map-error-to-react-stack.tsindex 2eb0eda423..12f6d27efe 100644--- a/packages/cli/src/preview-server/error-overlay/react-overlay/effects/map-error-to-react-stack.ts+++ b/packages/cli/src/preview-server/error-overlay/react-overlay/effects/map-error-to-react-stack.ts@@ -1,4 +1,4 @@-import {Internals} from 'remotion';+import {truthy} from '../../../../truthy';export type ErrorLocation = {fileName: string;@@ -57,6 +57,6 @@ export const getLocationFromBuildError = (err: Error): ErrorLocation | null => {fileName: filename.trim(),};})- .filter(Internals.truthy)[0] ?? null+ .filter(truthy)[0] ?? null);};diff --git a/packages/cli/src/preview-server/start-server.ts b/packages/cli/src/preview-server/start-server.tsindex d7a3089347..76ecdbdea8 100644--- a/packages/cli/src/preview-server/start-server.ts+++ b/packages/cli/src/preview-server/start-server.ts@@ -6,6 +6,7 @@ import fs from 'fs';import http from 'http';import os from 'os';import path from 'path';+// eslint-disable-next-line no-restricted-importsimport type {WebpackOverrideFn} from 'remotion';import {wdm} from './dev-middleware';import {webpackHotMiddleware} from './hot-middleware';diff --git a/packages/cli/src/previewEntry.tsx b/packages/cli/src/previewEntry.tsxindex cc99bbfe21..deb89f0499 100644--- a/packages/cli/src/previewEntry.tsx+++ b/packages/cli/src/previewEntry.tsx@@ -1,5 +1,6 @@import type {render} from 'react-dom';import ReactDOM from 'react-dom/client';+// eslint-disable-next-line no-restricted-importsimport {Internals} from 'remotion';import '../styles/styles.css';import {Editor} from './editor/components/Editor';diff --git a/packages/cli/src/progress-bar.ts b/packages/cli/src/progress-bar.tsindex 6246577cb3..169a6ee4a5 100644--- a/packages/cli/src/progress-bar.ts+++ b/packages/cli/src/progress-bar.ts@@ -1,12 +1,12 @@import {ConfigInternals} from '@remotion/config';import type {Codec, StitchingState} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';-import {Internals} from 'remotion';import {AnsiDiff} from './ansi/ansi-diff';import {chalk} from './chalk';import {makeMultiDownloadProgress} from './download-progress';import {makeProgressBar} from './make-progress-bar';import type {RenderStep} from './step';+import {truthy} from './truthy';export const createProgressBar = (quiet: boolean@@ -76,7 +76,7 @@ export const makeRenderingProgress = ({`(${steps.indexOf('rendering') + 1}/${steps.length})`,makeProgressBar(progress),[doneIn ? 'Rendered' : 'Rendering', `frames (${concurrency}x)`]- .filter(Internals.truthy)+ .filter(truthy).join(' '),doneIn === null ? `${frames}/${totalFrames}` : chalk.gray(`${doneIn}ms`),].join(' ');@@ -134,6 +134,6 @@ export const makeRenderingAndStitchingProgress = ({makeMultiDownloadProgress(downloads),stitching === null ? null : makeStitchingProgress(stitching),]- .filter(Internals.truthy)+ .filter(truthy).join('\n');};diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsxindex 0286f1def3..976532124f 100644--- a/packages/cli/src/render.tsx+++ b/packages/cli/src/render.tsx@@ -10,6 +10,7 @@ import {import fs from 'fs';import os from 'os';import path from 'path';+// eslint-disable-next-line no-restricted-importsimport {Internals} from 'remotion';import {chalk} from './chalk';import {diff --git a/packages/cli/src/still.ts b/packages/cli/src/still.tsindex 53bd26d39d..6657947400 100644--- a/packages/cli/src/still.ts+++ b/packages/cli/src/still.ts@@ -8,7 +8,6 @@ import {} from '@remotion/renderer';import {mkdirSync} from 'fs';import path from 'path';-import {Internals} from 'remotion';import {chalk} from './chalk';import {getAndValidateAbsoluteOutputFile,@@ -25,6 +24,7 @@ import {} from './progress-bar';import {bundleOnCli} from './setup-cache';import type {RenderStep} from './step';+import {truthy} from './truthy';import {getOutputLocation,getUserPassedOutputLocation,@@ -137,7 +137,7 @@ export const still = async () => {const steps: RenderStep[] = [RenderInternals.isServeUrl(fullPath) ? null : ('bundling' as const),'rendering' as const,- ].filter(Internals.truthy);+ ].filter(truthy);const urlOrBundle = RenderInternals.isServeUrl(fullPath)? Promise.resolve(fullPath)diff --git a/packages/cli/src/test/big-timeline.test.ts b/packages/cli/src/test/big-timeline.test.tsindex b16ebfca49..0f01254397 100644--- a/packages/cli/src/test/big-timeline.test.ts+++ b/packages/cli/src/test/big-timeline.test.ts@@ -1,3 +1,4 @@+// eslint-disable-next-line no-restricted-importsimport type {TSequence} from 'remotion';import {expect, test} from 'vitest';import {calculateTimeline} from '../editor/helpers/calculate-timeline';diff --git a/packages/cli/src/test/sequenced-timeline.test.ts b/packages/cli/src/test/sequenced-timeline.test.tsindex bae2bfccd3..2ddfc56c4f 100644--- a/packages/cli/src/test/sequenced-timeline.test.ts+++ b/packages/cli/src/test/sequenced-timeline.test.ts@@ -1,3 +1,4 @@+// eslint-disable-next-line no-restricted-importsimport type {TSequence} from 'remotion';import {expect, test} from 'vitest';import {calculateTimeline} from '../editor/helpers/calculate-timeline';diff --git a/packages/cli/src/truthy.ts b/packages/cli/src/truthy.tsnew file mode 100644index 0000000000..e186dc6277--- /dev/null+++ b/packages/cli/src/truthy.ts@@ -0,0 +1,5 @@+type Truthy<T> = T extends false | '' | 0 | null | undefined ? never : T; // from lodash++export function truthy<T>(value: T): value is Truthy<T> {+ return Boolean(value);+}diff --git a/packages/cli/src/webpack-cache.ts b/packages/cli/src/webpack-cache.tsindex 1d38c7eafd..4ddeb23ecc 100644--- a/packages/cli/src/webpack-cache.ts+++ b/packages/cli/src/webpack-cache.ts@@ -1,5 +1,6 @@import fs from 'fs';import path from 'path';+// eslint-disable-next-line no-restricted-importsimport {random} from 'remotion';type Environment = 'development' | 'production';