Skip to content

🎥 Make videos programmatically with React

awesome

Jonny Burger958da25ee73f
diff --git a/packages/.monorepo/builder.ts b/packages/.monorepo/builder.ts
index 918961009a..631d0ca7aa 100644
--- a/packages/.monorepo/builder.ts
+++ b/packages/.monorepo/builder.ts
@@ -29,10 +29,14 @@ const sortObject = (obj: Record<string, string>) => {
type FormatAction = 'do-nothing' | 'build' | 'use-tsc';
+type EntryPoint = {
+ target: 'node' | 'browser';
+ path: string;
+};
+
export const buildPackage = async ({
formats,
external,
- target,
entrypoints,
}: {
formats: {
@@ -40,16 +44,15 @@ export const buildPackage = async ({
cjs: FormatAction;
};
external: 'dependencies' | string[];
- target: 'node' | 'browser';
- entrypoints: string[];
+ entrypoints: EntryPoint[];
}) => {
console.time(`Generated.`);
const pkg = await Bun.file(path.join(process.cwd(), 'package.json')).json();
const newExports = {};
const versions = {};
- const firstNames = entrypoints.map((e) => {
- const splittedBySlash = e.split('/');
+ const firstNames = entrypoints.map(({path, target}) => {
+ const splittedBySlash = path.split('/');
const last = splittedBySlash[splittedBySlash.length - 1];
return last.split('.')[0];
});
@@ -60,23 +63,25 @@ export const buildPackage = async ({
continue;
} else if (action === 'use-tsc') {
} else if (action === 'build') {
- const output = await build({
- entrypoints: entrypoints.map((e) => path.join(process.cwd(), e)),
- naming: `[name].${format === 'esm' ? 'mjs' : 'js'}`,
- external: getExternal(external),
- target,
- format,
- });
+ for (const {path: p, target} of entrypoints) {
+ const output = await build({
+ entrypoints: [p],
+ naming: `[name].${format === 'esm' ? 'mjs' : 'js'}`,
+ external: getExternal(external),
+ target,
+ format,
+ });
- for (const file of output.outputs) {
- const text = await file.text();
+ for (const file of output.outputs) {
+ const text = await file.text();
- const outputPath = `./${path.join('./dist', format, file.path)}`;
+ const outputPath = `./${path.join('./dist', format, file.path)}`;
- await Bun.write(path.join(process.cwd(), outputPath), text);
+ await Bun.write(path.join(process.cwd(), outputPath), text);
- if (text.includes('jonathanburger')) {
- throw new Error('Absolute path was included, see ' + outputPath);
+ if (text.includes('jonathanburger')) {
+ throw new Error('Absolute path was included, see ' + outputPath);
+ }
}
}
}
diff --git a/packages/eslint-plugin/bundle.ts b/packages/eslint-plugin/bundle.ts
index 963d906f03..91999f2a86 100644
--- a/packages/eslint-plugin/bundle.ts
+++ b/packages/eslint-plugin/bundle.ts
@@ -6,6 +6,10 @@ await buildPackage({
esm: 'build',
},
external: ['@typescript-eslint/utils'],
- target: 'node',
- entrypoints: ['src/index.ts'],
+ entrypoints: [
+ {
+ path: 'src/index.ts',
+ target: 'node',
+ },
+ ],
});
diff --git a/packages/lambda-client/bundle.ts b/packages/lambda-client/bundle.ts
index 486c75bbe4..f5b0d48f73 100644
--- a/packages/lambda-client/bundle.ts
+++ b/packages/lambda-client/bundle.ts
@@ -6,6 +6,15 @@ await buildPackage({
esm: 'build',
},
external: 'dependencies',
- target: 'node',
- entrypoints: ['src/index.ts', 'src/constants.ts', 'src/regions.ts'],
+ entrypoints: [
+ {
+ path: 'src/index.ts',
+ target: 'node',
+ },
+ {
+ path: 'src/constants.ts',
+ target: 'browser',
+ },
+ {path: 'src/regions.ts', target: 'browser'},
+ ],
});
diff --git a/packages/serverless-client/bundle.ts b/packages/serverless-client/bundle.ts
index df3f2f9290..c68993a090 100644
--- a/packages/serverless-client/bundle.ts
+++ b/packages/serverless-client/bundle.ts
@@ -6,6 +6,10 @@ await buildPackage({
esm: 'build',
},
external: [],
- target: 'node',
- entrypoints: ['src/index.ts'],
+ entrypoints: [
+ {
+ path: 'src/index.ts',
+ target: 'node',
+ },
+ ],
});