Skip to content

🎥 Make videos programmatically with React

alright

Jonny Burger12026a903f6e
diff --git a/packages/.monorepo/builder.ts b/packages/.monorepo/builder.ts
index d4bb42f82b..9bfd80374e 100644
--- a/packages/.monorepo/builder.ts
+++ b/packages/.monorepo/builder.ts
@@ -1,6 +1,6 @@
import {build} from 'bun';
-import {existsSync} from 'node:fs';
import path from 'path';
+import {validateExports} from './validate-exports';
if (process.env.NODE_ENV !== 'production') {
throw new Error('This script must be run using NODE_ENV=production');
@@ -8,42 +8,6 @@ if (process.env.NODE_ENV !== 'production') {
type Format = 'esm' | 'cjs';
-const validateExports = (
- exports: Record<string, './package.json' | Record<string, string>>,
-) => {
- const keys = Object.keys(exports);
- for (const key of keys) {
- const value = exports[key];
- if (key === './package.json' && value === './package.json') {
- continue;
- }
-
- if (typeof value === 'string') {
- throw new Error(`Invalid export for ${key}`);
- }
-
- if (!value.import || !value.require || !value.module || !value) {
- throw new Error(`Missing import or require for ${key}`);
- }
- const paths = Object.keys(value);
- for (const entry of paths) {
- if (
- entry !== 'import' &&
- entry !== 'require' &&
- entry !== 'module' &&
- entry !== 'types'
- ) {
- throw new Error(`Invalid export: ${entry}: ${JSON.stringify(exports)}`);
- }
- const pathToCheck = path.join(process.cwd(), value[entry]);
- const exists = existsSync(pathToCheck);
- if (!exists) {
- throw new Error(`Path does not exist: ${pathToCheck}`);
- }
- }
- }
-};
-
const getExternal = (deps: string[] | 'dependencies'): string[] => {
if (deps === 'dependencies') {
return Object.keys(
diff --git a/packages/.monorepo/validate-exports.ts b/packages/.monorepo/validate-exports.ts
new file mode 100644
index 0000000000..e3e409ba64
--- /dev/null
+++ b/packages/.monorepo/validate-exports.ts
@@ -0,0 +1,38 @@
+import {existsSync} from 'node:fs';
+import path from 'path';
+
+export const validateExports = (
+ exports: Record<string, './package.json' | Record<string, string>>,
+) => {
+ const keys = Object.keys(exports);
+ for (const key of keys) {
+ const value = exports[key];
+ if (key === './package.json' && value === './package.json') {
+ continue;
+ }
+
+ if (typeof value === 'string') {
+ throw new Error(`Invalid export for ${key}`);
+ }
+
+ if (!value.import || !value.require || !value.module || !value) {
+ throw new Error(`Missing import or require for ${key}`);
+ }
+ const paths = Object.keys(value);
+ for (const entry of paths) {
+ if (
+ entry !== 'import' &&
+ entry !== 'require' &&
+ entry !== 'module' &&
+ entry !== 'types'
+ ) {
+ throw new Error(`Invalid export: ${entry}: ${JSON.stringify(exports)}`);
+ }
+ const pathToCheck = path.join(process.cwd(), value[entry]);
+ const exists = existsSync(pathToCheck);
+ if (!exists) {
+ throw new Error(`Path does not exist: ${pathToCheck}`);
+ }
+ }
+ }
+};