Skip to content

🎥 Make videos programmatically with React

Bundle Skia with Bun

Jonny Burger9fa14da82a4b
diff --git a/packages/skia/bundle.ts b/packages/skia/bundle.ts
new file mode 100644
index 0000000000..5b3b6ee0ab
--- /dev/null
+++ b/packages/skia/bundle.ts
@@ -0,0 +1,32 @@
+import {build} from 'bun';
+
+const mainModule = await build({
+ entrypoints: ['src/index.ts'],
+ naming: '[name].mjs',
+ external: [
+ 'react',
+ 'remotion',
+ 'remotion/no-react',
+ 'react/jsx-runtime',
+ '@shopify/react-native-skia',
+ ],
+});
+
+const [file] = mainModule.outputs;
+const text = await file.text();
+
+await Bun.write('dist/esm/index.mjs', text);
+
+const skiaModule = await build({
+ entrypoints: ['src/enable.ts'],
+ naming: '[name].mjs',
+ target: 'node',
+ external: ['@remotion/bundler', 'canvaskit-wasm/bin/full/canvaskit.wasm'],
+});
+
+const [enableFile] = skiaModule.outputs;
+const skiaEnable = await enableFile.text();
+
+await Bun.write('dist/esm/enable.mjs', skiaEnable);
+
+export {};
diff --git a/packages/skia/package.json b/packages/skia/package.json
index 94d27e6045..c1a925814e 100644
--- a/packages/skia/package.json
+++ b/packages/skia/package.json
@@ -10,7 +10,7 @@
"formatting": "prettier src --check",
"lint": "eslint src --ext ts,tsx",
"watch": "tsc -w",
- "build": "rollup --config rollup-enable.config.js && rollup --config rollup.config.js && tsc -d"
+ "build": "bun bundle.ts && tsc -d"
},
"author": "Jonny Burger <[email protected]>, William Candillon <[email protected]>",
"contributors": [],
@@ -32,7 +32,6 @@
"devDependencies": {
"@jonny/eslint-config": "3.0.281",
"@remotion/bundler": "workspace:*",
- "@rollup/plugin-typescript": "^8.2.0",
"@shopify/react-native-skia": "^1.2.2",
"@types/react": "18.2.48",
"@types/react-native": "^0.69.2",
@@ -41,8 +40,7 @@
"prettier-plugin-organize-imports": "3.2.4",
"react": "18.2.0",
"react-dom": "18.2.0",
- "remotion": "workspace:*",
- "rollup": "^2.70.1"
+ "remotion": "workspace:*"
},
"keywords": [
"remotion",
diff --git a/packages/skia/rollup-enable.config.js b/packages/skia/rollup-enable.config.js
deleted file mode 100644
index 1adb14e52d..0000000000
--- a/packages/skia/rollup-enable.config.js
+++ /dev/null
@@ -1,23 +0,0 @@
-// rollup.config.js
-import typescript from '@rollup/plugin-typescript';
-
-export default [
- {
- input: 'src/enable.ts',
- output: [
- {
- file: 'dist/esm/enable.mjs',
- format: 'es',
- sourcemap: false,
- },
- ],
- external: ['react', '@remotion/bundler', 'fs'],
- plugins: [
- typescript({
- tsconfig: 'tsconfig-esm.json',
- sourceMap: false,
- outputToFilesystem: true,
- }),
- ],
- },
-];
diff --git a/packages/skia/rollup.config.js b/packages/skia/rollup.config.js
deleted file mode 100644
index 1862a3de46..0000000000
--- a/packages/skia/rollup.config.js
+++ /dev/null
@@ -1,28 +0,0 @@
-// rollup.config.js
-import typescript from '@rollup/plugin-typescript';
-
-export default [
- {
- input: 'src/index.ts',
- output: [
- {
- file: 'dist/esm/index.mjs',
- format: 'es',
- sourcemap: false,
- },
- ],
- external: [
- 'react',
- 'remotion',
- 'react/jsx-runtime',
- '@shopify/react-native-skia',
- ],
- plugins: [
- typescript({
- tsconfig: 'tsconfig-esm.json',
- sourceMap: false,
- outputToFilesystem: true,
- }),
- ],
- },
-];
diff --git a/packages/skia/tsconfig-esm.json b/packages/skia/tsconfig-esm.json
deleted file mode 100644
index 805e1f04d2..0000000000
--- a/packages/skia/tsconfig-esm.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "extends": "../tsconfig-esm.settings.json",
- "compilerOptions": {
- "rootDir": "./src",
- "outDir": "./dist/esm",
- "skipLibCheck": true,
- "jsx": "react-jsx",
- "moduleResolution": "node"
- },
- "references": [{"path": "../core"}],
- "include": ["./src"]
-}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 783bb9ec8d..a4dca68dd7 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1867,9 +1867,6 @@ importers:
'@remotion/bundler':
specifier: workspace:*
version: link:../bundler
- '@rollup/plugin-typescript':
- specifier: ^8.2.0
'@shopify/react-native-skia':
specifier: ^1.2.2
version: 1.2.2([email protected])
@@ -1894,9 +1891,6 @@ importers:
react-dom:
specifier: 18.2.0
version: 18.2.0([email protected])
- rollup:
- specifier: ^2.70.1
- version: 2.76.0
packages/studio:
dependencies: