Skip to content

🎥 Make videos programmatically with React

support esm for lottie

Jonny Burger7867ca8c56c7
diff --git a/packages/lottie/package.json b/packages/lottie/package.json
index 0e8b671e09..2caefa73e7 100644
--- a/packages/lottie/package.json
+++ b/packages/lottie/package.json
@@ -2,12 +2,14 @@
"name": "@remotion/lottie",
"version": "3.3.62",
"description": "Remotion Lottie",
- "main": "dist/index.js",
+ "main": "dist/cjs/index.js",
+ "types": "dist/cjs/index.d.ts",
+ "module": "dist/esm/index.mjs",
"sideEffects": false,
"scripts": {
"lint": "eslint src --ext ts,tsx",
"test": "vitest --run",
- "build": "tsc -d",
+ "build": "rollup --config rollup.config.js && tsc -d",
"watch": "tsc -w"
},
"repository": {
@@ -34,16 +36,27 @@
"react": ">=16.8.0",
"react-dom": ">=16.8.0"
},
+ "exports": {
+ "./package.json": "./package.json",
+ ".": {
+ "types": "./dist/cjs/index.d.ts",
+ "module": "./dist/esm/index.mjs",
+ "import": "./dist/esm/index.mjs",
+ "require": "./dist/cjs/index.js"
+ }
+ },
"devDependencies": {
"@jonny/eslint-config": "3.0.266",
"@types/node": "^16.7.5",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.10",
+ "@rollup/plugin-typescript": "^8.2.0",
"eslint": "8.25.0",
"prettier": "^2.7.1",
"prettier-plugin-organize-imports": "^2.3.4",
"react": "^18.0.0",
"react-dom": "^18.0.0",
+ "rollup": "^2.70.1",
"typescript": "^4.7.0",
"vitest": "0.24.3"
},
diff --git a/packages/lottie/rollup.config.js b/packages/lottie/rollup.config.js
new file mode 100644
index 0000000000..60c3873b68
--- /dev/null
+++ b/packages/lottie/rollup.config.js
@@ -0,0 +1,23 @@
+// 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', 'lottie-web'],
+ plugins: [
+ typescript({
+ tsconfig: 'tsconfig-esm.json',
+ sourceMap: false,
+ outputToFilesystem: true,
+ }),
+ ],
+ },
+];
diff --git a/packages/lottie/tsconfig-esm.json b/packages/lottie/tsconfig-esm.json
new file mode 100644
index 0000000000..93ac160761
--- /dev/null
+++ b/packages/lottie/tsconfig-esm.json
@@ -0,0 +1,13 @@
+{
+ "extends": "../tsconfig-esm.settings.json",
+ "compilerOptions": {
+ "composite": true,
+ "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 607e1d5121..5cd6744d96 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -714,6 +714,7 @@ importers:
packages/lottie:
specifiers:
'@jonny/eslint-config': 3.0.266
+ '@rollup/plugin-typescript': ^8.2.0
'@types/node': ^16.7.5
'@types/react': 18.0.26
'@types/react-dom': 18.0.10
@@ -724,6 +725,7 @@ importers:
react: ^18.0.0
react-dom: ^18.0.0
remotion: 3.3.62
+ rollup: ^2.70.1
typescript: ^4.7.0
vitest: 0.24.3
dependencies:
@@ -731,6 +733,7 @@ importers:
remotion: link:../core
devDependencies:
'@jonny/eslint-config': 3.0.266_t54va6jeo5lf3vtqih5uiyrm5e
+ '@rollup/plugin-typescript': 8.5.0_2s5nfqwcf62746iqzotp3mpuy4
'@types/node': 16.10.2
'@types/react': 18.0.26
'@types/react-dom': 18.0.10
@@ -739,6 +742,7 @@ importers:
prettier-plugin-organize-imports: 2.3.4_j2odc4yr77iddtreafyicbq5hi
react: 18.0.0
react-dom: [email protected]
+ rollup: 2.76.0
typescript: 4.7.2
vitest: 0.24.3