Skip to content

🎥 Make videos programmatically with React

make CJS with rollup

Jonny Burger3e82d016d0ea
diff --git a/packages/transitions/.gitignore b/packages/transitions/.gitignore
index 75788d003a..f7f33a1696 100644
--- a/packages/transitions/.gitignore
+++ b/packages/transitions/.gitignore
@@ -1,2 +1,3 @@
dist-cjs
tsconfig-cjs.tsbuildinfo
+.rollup.cache
diff --git a/packages/transitions/package.json b/packages/transitions/package.json
index 27f127f82f..ae5ce8cbf4 100644
--- a/packages/transitions/package.json
+++ b/packages/transitions/package.json
@@ -10,7 +10,8 @@
"scripts": {
"lint": "eslint src --ext ts,tsx",
"watch": "tsc -w",
- "build": "tsc -d"
+ "build": "rollup --config rollup.config.js && tsc -d"
+
},
"author": "Jonny Burger",
"contributors": [],
@@ -36,7 +37,9 @@
"@types/react": "18.0.26",
"@types/react-dom": "18.0.11",
"@remotion/test-utils": "workspace:*",
- "@vitejs/plugin-react": "^2.0.0"
+ "@vitejs/plugin-react": "^2.0.0",
+ "rollup": "^2.70.1",
+ "@rollup/plugin-typescript": "^8.2.0"
},
"peerDependencies": {
"react": ">=16.8.0",
@@ -53,21 +56,26 @@
".": {
"module": "./dist/index.js",
"import": "./dist/index.js",
- "types": "./dist/index.d.ts"
+ "types": "./dist/index.d.ts",
+ "require": "./dist/cjs/index.js"
+
},
"./fade": {
"module": "./dist/presentations/fade.js",
"import": "./dist/presentations/fade.js",
+ "require": "./dist/cjs/presentations/fade.js",
"types": "./dist/presentations/fade.d.ts"
},
"./slide": {
"module": "./dist/presentations/slide.js",
"import": "./dist/presentations/slide.js",
+ "require": "./dist/cjs/presentations/slide.js",
"types": "./dist/presentations/slide.d.ts"
},
"./wipe": {
"module": "./dist/presentations/wipe.js",
"import": "./dist/presentations/wipe.js",
+ "require": "./dist/cjs/presentations/wipe.js",
"types": "./dist/presentations/wipe.d.ts"
},
"./package.json": "./package.json"
diff --git a/packages/transitions/rollup.config.js b/packages/transitions/rollup.config.js
new file mode 100644
index 0000000000..002eda4bb4
--- /dev/null
+++ b/packages/transitions/rollup.config.js
@@ -0,0 +1,77 @@
+// rollup.config.js
+import typescript from '@rollup/plugin-typescript';
+
+export default [
+ {
+ input: 'src/index.ts',
+ output: [
+ {
+ file: 'dist/cjs/index.js',
+ format: 'cjs',
+ sourcemap: false,
+ },
+ ],
+ external: ['remotion', 'react', 'react/jsx-runtime'],
+ plugins: [
+ typescript({
+ tsconfig: 'tsconfig-cjs.json',
+ sourceMap: false,
+ outputToFilesystem: true,
+ }),
+ ],
+ },
+ {
+ input: 'src/presentations/slide.tsx',
+ output: [
+ {
+ file: 'dist/cjs/slide.js',
+ format: 'cjs',
+ sourcemap: false,
+ },
+ ],
+ external: ['remotion', 'react', 'react/jsx-runtime'],
+ plugins: [
+ typescript({
+ tsconfig: 'tsconfig-cjs.json',
+ sourceMap: false,
+ outputToFilesystem: true,
+ }),
+ ],
+ },
+ {
+ input: 'src/presentations/fade.tsx',
+ output: [
+ {
+ file: 'dist/cjs/fade.js',
+ format: 'cjs',
+ sourcemap: false,
+ },
+ ],
+ external: ['remotion', 'react', 'react/jsx-runtime'],
+ plugins: [
+ typescript({
+ tsconfig: 'tsconfig-cjs.json',
+ sourceMap: false,
+ outputToFilesystem: true,
+ }),
+ ],
+ },
+ {
+ input: 'src/presentations/wipe.tsx',
+ output: [
+ {
+ file: 'dist/cjs/wipe.js',
+ format: 'cjs',
+ sourcemap: false,
+ },
+ ],
+ external: ['remotion', 'react', 'react/jsx-runtime'],
+ plugins: [
+ typescript({
+ tsconfig: 'tsconfig-cjs.json',
+ sourceMap: false,
+ outputToFilesystem: true,
+ }),
+ ],
+ },
+];
diff --git a/packages/transitions/tsconfig-cjs.json b/packages/transitions/tsconfig-cjs.json
index ff23fada7b..1adeffeaae 100644
--- a/packages/transitions/tsconfig-cjs.json
+++ b/packages/transitions/tsconfig-cjs.json
@@ -3,7 +3,7 @@
"compilerOptions": {
"composite": true,
"rootDir": "src",
- "outDir": "dist-cjs",
+ "outDir": "xxxx",
},
"include": ["src"],
"references": [{ "path": "../core" }, { "path": "../test-utils" }]
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index c02c51d51b..94686f2036 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1847,6 +1847,9 @@ importers:
'@remotion/test-utils':
specifier: workspace:*
version: link:../test-utils
+ '@rollup/plugin-typescript':
+ specifier: ^8.2.0
'@types/react':
specifier: 18.0.26
version: 18.0.26
@@ -1871,6 +1874,9 @@ importers:
react-dom:
specifier: 18.0.0
version: 18.0.0([email protected])
+ rollup:
+ specifier: ^2.70.1
+ version: 2.76.0
vitest:
specifier: 0.31.1
version: 0.31.1([email protected])