Skip to content

🎥 Make videos programmatically with React

webcodecs ESM module

Jonny Burger44b81361e6da
diff --git a/packages/webcodecs/bundle.ts b/packages/webcodecs/bundle.ts
new file mode 100644
index 0000000000..e4ac0181d1
--- /dev/null
+++ b/packages/webcodecs/bundle.ts
@@ -0,0 +1,18 @@
+import {build} from 'bun';
+
+if (process.env.NODE_ENV !== 'production') {
+ throw new Error('This script must be run using NODE_ENV=production');
+}
+
+const output = await build({
+ entrypoints: ['src/index.ts'],
+ naming: '[name].mjs',
+ external: ['@remotion/media-parser'],
+});
+
+const [file] = output.outputs;
+const text = await file.text();
+
+await Bun.write('dist/esm/index.mjs', text);
+
+export {};
diff --git a/packages/webcodecs/package.json b/packages/webcodecs/package.json
index d3f8334f0b..cca7087dbc 100644
--- a/packages/webcodecs/package.json
+++ b/packages/webcodecs/package.json
@@ -2,6 +2,8 @@
"name": "@remotion/webcodecs",
"version": "4.0.209",
"main": "dist/index.js",
+ "types": "dist/index.d.ts",
+ "module": "dist/esm/index.mjs",
"sideEffects": false,
"repository": {
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/webcodecs"
@@ -12,7 +14,7 @@
"scripts": {
"formatting": "prettier src --check",
"lint": "eslint src --ext ts,tsx",
- "build": "tsc -d",
+ "build": "tsc -d && bun --env-file=../.env.bundle bundle.ts",
"watch": "tsc -w"
},
"files": [
@@ -20,12 +22,16 @@
],
"author": "Jonny Burger <[email protected]>",
"license": "SEE LICENSE IN LICENSE.md",
- "dependencies": {},
+ "dependencies": {
+ "@remotion/media-parser": "workspace:*"
+ },
"peerDependencies": {},
"devDependencies": {
- "@remotion/media-parser": "workspace:*",
"@types/dom-webcodecs": "0.1.11"
},
"keywords": [],
+ "publishConfig": {
+ "access": "public"
+ },
"description": "Private experimental package"
}