Skip to content

πŸŽ₯ Make videos programmatically with React

nice

JonnyBurger5774cf76ff3d
diff --git a/.claude/skills/add-new-package/SKILL.md b/.claude/skills/add-new-package/SKILL.md
index 17714cf648..40f6f08554 100644
--- a/.claude/skills/add-new-package/SKILL.md
+++ b/.claude/skills/add-new-package/SKILL.md
@@ -3,12 +3,12 @@
## Steps
1. **Create `packages/<name>/`** with these files:
- - `package.json` β€” copy from `@remotion/motion-blur` as template; update name, description, homepage, dependencies
- - `tsconfig.json` β€” extends `../tsconfig.settings.json`, rootDir `src`, outDir `dist/cjs`, reference `../core`
+ - `package.json` β€” copy from `@remotion/light-leaks` as template; update name, description, homepage, dependencies
+ - `tsconfig.json` β€” extends `../tsconfig.settings.json`, uses tsgo with `emitDeclarationOnly: true`, `outDir: "dist"`, `module: "es2020"`, `moduleResolution: "bundler"`, `target: "ES2022"`
- `src/index.ts` β€” exports
- - `bundle.ts` β€” Bun build script, externalize `react`, `remotion`, `remotion/no-react`, `react/jsx-runtime`
+ - `bundle.ts` β€” Bun build script, externalize `react`, `remotion`, `remotion/no-react`, `react/jsx-runtime`, `react/jsx-dev-runtime`, `react-dom`
- `eslint.config.mjs` β€” use `remotionFlatConfig({react: true})` if React, `{react: false}` otherwise
- - `.npmignore` β€” copy from `@remotion/noise`
+ - `.npmignore` β€” copy from `@remotion/light-leaks`
- `README.md` β€” package name, description, install command, link to docs
2. **Register in monorepo:**
@@ -23,9 +23,10 @@
- `table-of-contents.tsx` β€” TOCItem grid linking to component/function pages
- Individual component/function `.mdx` pages
- Edit `packages/docs/sidebars.ts` β€” add category
- - Edit `packages/docs/src/data/articles.ts` β€” add entries alphabetically
- Edit `packages/docs/components/TableOfContents/api.tsx` β€” import table of contents and add section
+See the `writing-docs` skill for details on writing documentation.
+
4. **Example usage:**
- Add `"@remotion/<name>": "workspace:*"` to `packages/example/package.json`
- Create `packages/example/src/<Name>/index.tsx`
@@ -38,11 +39,15 @@
## Version
-Use the current version from `packages/core/src/version.ts`.
+Use the current version from `packages/core/src/version.ts`.
+For the documentation version, increment the patch version by 1 as it will only be released with the next Remotion release.
## Patterns
- Use `"workspace:*"` for internal dependencies
- Use `"catalog:"` for shared external dependency versions
-- The `make` script is: `tsc -d && bun --env-file=../.env.bundle bundle.ts`
+- The `make` script is: `tsgo && bun --env-file=../.env.bundle bundle.ts`
+- Add `"type": "module"` to `package.json`
+- Add `"@typescript/native-preview": "catalog:"` to devDependencies
+- Types/main point to `dist/index.d.ts` and `dist/index.js` (not `dist/cjs/`)
- Packages with React components need `peerDependencies` for `react` and `react-dom`
diff --git a/bun.lock b/bun.lock
index 6f801ea132..422c989f28 100644
--- a/bun.lock
+++ b/bun.lock
@@ -891,10 +891,10 @@
},
"devDependencies": {
"@remotion/eslint-config-internal": "workspace:*",
+ "@typescript/native-preview": "catalog:",
"eslint": "catalog:",
"react": "catalog:",
"react-dom": "catalog:",
- "remotion": "workspace:*",
},
"peerDependencies": {
"react": ">=16.8.0",
diff --git a/packages/light-leaks/bundle.ts b/packages/light-leaks/bundle.ts
index b6fef6a414..846bbbc8a0 100644
--- a/packages/light-leaks/bundle.ts
+++ b/packages/light-leaks/bundle.ts
@@ -1,14 +1,34 @@
import {build} from 'bun';
+import path from 'path';
+if (process.env.NODE_ENV !== 'production') {
+ throw new Error('This script must be run using NODE_ENV=production');
+}
+
+console.time('Generated.');
const output = await build({
entrypoints: ['src/index.ts'],
naming: '[name].mjs',
- external: ['react', 'remotion', 'remotion/no-react', 'react/jsx-runtime'],
+ external: [
+ 'remotion',
+ 'remotion/no-react',
+ 'react',
+ 'react/jsx-runtime',
+ 'react/jsx-dev-runtime',
+ 'react-dom',
+ ],
});
-const [file] = output.outputs;
-const text = await file.text();
+if (!output.success) {
+ console.log(output.logs.join('\n'));
+ process.exit(1);
+}
+
+for (const file of output.outputs) {
+ const str = await file.text();
+ const out = path.join('dist', 'esm', file.path);
-await Bun.write('dist/esm/index.mjs', text);
+ await Bun.write(out, str);
+}
-export {};
+console.timeEnd('Generated.');
diff --git a/packages/light-leaks/package.json b/packages/light-leaks/package.json
index c752fe9dda..e412c4dcc9 100644
--- a/packages/light-leaks/package.json
+++ b/packages/light-leaks/package.json
@@ -1,18 +1,20 @@
{
- "repository": {
- "url": "https://github.com/remotion-dev/remotion/tree/main/packages/light-leaks"
- },
"name": "@remotion/light-leaks",
"version": "4.0.414",
"description": "Light leak effects for Remotion",
- "main": "dist/cjs/index.js",
- "types": "dist/cjs/index.d.ts",
+ "main": "dist/index.js",
+ "types": "dist/index.d.ts",
"module": "dist/esm/index.mjs",
+ "repository": {
+ "url": "https://github.com/remotion-dev/remotion/tree/main/packages/light-leaks"
+ },
"sideEffects": false,
+ "type": "module",
"scripts": {
"formatting": "prettier --experimental-cli src --check",
"lint": "eslint src",
- "make": "tsc -d && bun --env-file=../.env.bundle bundle.ts"
+ "watch": "tsgo -w",
+ "make": "tsgo && bun --env-file=../.env.bundle bundle.ts"
},
"author": "Jonny Burger <[email protected]>",
"contributors": [],
@@ -28,20 +30,19 @@
"react-dom": ">=16.8.0"
},
"exports": {
- "./package.json": "./package.json",
".": {
- "types": "./dist/cjs/index.d.ts",
+ "types": "./dist/index.d.ts",
"module": "./dist/esm/index.mjs",
- "import": "./dist/esm/index.mjs",
- "require": "./dist/cjs/index.js"
- }
+ "import": "./dist/esm/index.mjs"
+ },
+ "./package.json": "./package.json"
},
"devDependencies": {
"react": "catalog:",
"react-dom": "catalog:",
- "remotion": "workspace:*",
"@remotion/eslint-config-internal": "workspace:*",
- "eslint": "catalog:"
+ "eslint": "catalog:",
+ "@typescript/native-preview": "catalog:"
},
"keywords": [
"remotion",
diff --git a/packages/light-leaks/tsconfig.json b/packages/light-leaks/tsconfig.json
index fe046539de..caccee4637 100644
--- a/packages/light-leaks/tsconfig.json
+++ b/packages/light-leaks/tsconfig.json
@@ -2,13 +2,14 @@
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
- "outDir": "dist/cjs",
- "skipLibCheck": true
+ "outDir": "dist",
+ "jsx": "react-jsx",
+ "skipLibCheck": true,
+ "target": "ES2022",
+ "module": "es2020",
+ "moduleResolution": "bundler",
+ "declaration": true,
+ "emitDeclarationOnly": true
},
- "include": ["src"],
- "references": [
- {
- "path": "../core"
- }
- ]
+ "include": ["src"]
}