Skip to content

🎥 Make videos programmatically with React

`@remotion/eslint-plugin`: Bundle big dependency

Jonny Burger4c2cf91aa1ec
diff --git a/packages/eslint-plugin/bundle.ts b/packages/eslint-plugin/bundle.ts
new file mode 100644
index 0000000000..d89852ea5c
--- /dev/null
+++ b/packages/eslint-plugin/bundle.ts
@@ -0,0 +1,24 @@
+import {build} from 'bun';
+
+if (process.env.NODE_ENV !== 'production') {
+ throw new Error('This script must be run using NODE_ENV=production');
+}
+
+const formats = ['esm', 'cjs'] as const;
+
+for (const format of formats) {
+ const output = await build({
+ entrypoints: ['src/index.ts'],
+ naming: `[name].${format === 'esm' ? 'mjs' : 'js'}`,
+ external: [],
+ target: 'node',
+ });
+
+ const [file] = output.outputs;
+ const text = await file.text();
+
+ await Bun.write(
+ `dist/${format}/index.${format === 'esm' ? 'mjs' : 'js'}`,
+ text,
+ );
+}
diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json
index 1f461e1ffd..6411543ca3 100644
--- a/packages/eslint-plugin/package.json
+++ b/packages/eslint-plugin/package.json
@@ -7,7 +7,7 @@
"description": "Rules for writing Remotion code",
"scripts": {
"test": "vitest --run",
- "make": "tsc -d"
+ "make": "tsc -d && bun --env-file=../.env.bundle bundle.ts"
},
"main": "dist/index.js",
"bugs": {
@@ -15,9 +15,7 @@
},
"author": "Jonny Burger <[email protected]>",
"license": "ISC",
- "dependencies": {
- "@typescript-eslint/utils": "5.19.0"
- },
+ "dependencies": {},
"keywords": [
"eslint",
"eslintplugin"
@@ -26,8 +24,18 @@
"eslint": ">=7.0.0"
},
"devDependencies": {
+ "@typescript-eslint/utils": "5.19.0",
"vitest": "0.31.1"
},
+ "exports": {
+ ".": {
+ "import": "./dist/esm/index.mjs",
+ "module": "./dist/esm/index.mjs",
+ "require": "./dist/cjs/index.js",
+ "types": "./dist/index.d.ts"
+ },
+ "./package.json": "./package.json"
+ },
"private": false,
"homepage": "https://www.remotion.dev/docs/brownfield#install-the-eslint-plugin"
}
diff --git a/packages/eslint-plugin/tsconfig.json b/packages/eslint-plugin/tsconfig.json
index 63c908d96a..05f6f1f7c8 100644
--- a/packages/eslint-plugin/tsconfig.json
+++ b/packages/eslint-plugin/tsconfig.json
@@ -1,10 +1,11 @@
{
- "extends": "../tsconfig.settings.json",
- "compilerOptions": {
- "rootDir": "./src",
- "outDir": "./dist",
- "skipLibCheck": true,
- "jsx": "react-jsx"
- },
- "include": ["./src"]
+ "extends": "../tsconfig.settings.json",
+ "compilerOptions": {
+ "rootDir": "./src",
+ "outDir": "./dist",
+ "skipLibCheck": true,
+ "jsx": "react-jsx",
+ "emitDeclarationOnly": true
+ },
+ "include": ["./src"]
}