Skip to content

🎥 Make videos programmatically with React

`@remotion/captions`: Add CommonJS export (#10674)

Jonny Burger46672cc65283
diff --git a/packages/captions/bundle.ts b/packages/captions/bundle.ts
new file mode 100644
index 0000000000..24f8465e8e
--- /dev/null
+++ b/packages/captions/bundle.ts
@@ -0,0 +1,17 @@
+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',
+});
+
+const [file] = output.outputs;
+const text = await file.text();
+
+await Bun.write('dist/esm/index.mjs', text);
+
+export {};
diff --git a/packages/captions/package.json b/packages/captions/package.json
index dbc9ce9e5d..056dca6c0e 100644
--- a/packages/captions/package.json
+++ b/packages/captions/package.json
@@ -6,6 +6,8 @@
"version": "4.0.514",
"description": "Primitives for dealing with captions",
"main": "dist/index.js",
+ "types": "dist/index.d.ts",
+ "module": "dist/esm/index.mjs",
"bugs": {
"url": "https://github.com/remotion-dev/remotion/issues"
},
@@ -14,7 +16,7 @@
"format": "oxfmt src",
"lint": "eslint src",
"test": "bun test src",
- "make": "tsgo -d"
+ "make": "tsgo -d && bun --env-file=../.env.bundle bundle.ts"
},
"author": "Jonny Burger <[email protected]>",
"license": "MIT",
@@ -28,6 +30,15 @@
"keywords": [
"remotion"
],
+ "exports": {
+ "./package.json": "./package.json",
+ ".": {
+ "types": "./dist/index.d.ts",
+ "module": "./dist/esm/index.mjs",
+ "import": "./dist/esm/index.mjs",
+ "require": "./dist/index.js"
+ }
+ },
"publishConfig": {
"access": "public"
},