🎥 Make videos programmatically with React
build infra
Jonny Burgerc6874a75248a
diff --git a/packages/.monorepo/builder.ts b/packages/.monorepo/builder.tsnew file mode 100644index 0000000000..800690a446--- /dev/null+++ b/packages/.monorepo/builder.ts@@ -0,0 +1,43 @@+import {build} from 'bun';+import path from 'path';++if (process.env.NODE_ENV !== 'production') {+ throw new Error('This script must be run using NODE_ENV=production');+}++type Format = 'esm' | 'cjs';++export const buildPackage = async ({+ formats,+ external,+ target,+ entrypoints,+}: {+ formats: Format[];+ external: string[];+ target: 'node' | 'browser';+ entrypoints: string[];+}) => {+ for (const format of formats) {+ console.time(`Generated ${format}.`);+ const output = await build({+ entrypoints: entrypoints.map((e) => path.join(process.cwd(), e)),+ naming: `[name].${format === 'esm' ? 'mjs' : 'js'}`,+ external,+ target,+ format,+ });+ if (!output.success) {+ throw new Error('Build failed');+ }++ const [file] = output.outputs;+ const text = await file.text();++ await Bun.write(+ `dist/${format}/index.${format === 'esm' ? 'mjs' : 'js'}`,+ text,+ );+ console.timeEnd(`Generated ${format}.`);+ }+};diff --git a/packages/eslint-plugin/bundle.ts b/packages/eslint-plugin/bundle.tsindex 4e2f819e8e..040852e379 100644--- a/packages/eslint-plugin/bundle.ts+++ b/packages/eslint-plugin/bundle.ts@@ -1,25 +1,8 @@-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',- format- });-- const [file] = output.outputs;- const text = await file.text();-- await Bun.write(- `dist/${format}/index.${format === 'esm' ? 'mjs' : 'js'}`,- text,- );-}+import {buildPackage} from '../.monorepo/builder';++await buildPackage({+ formats: ['cjs', 'esm'],+ external: [],+ target: 'node',+ entrypoints: ['src/index.ts'],+});