Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-rad-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
run: npm ci

- name: Build
run: npm run build
run: npm run build:rollup
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: npm ci

- name: Build Package
run: npm run build
run: npm run build:rollup

- name: Get current version
id: package_version
Expand Down
33 changes: 33 additions & 0 deletions build-components.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// build-components.js
const esbuild = require('esbuild');
const fs = require('fs');
const path = require('path');

const componentsPath = path.resolve(__dirname, 'src/components/ui');
const outDir = path.resolve(__dirname, 'dist/temp-cleanup');

if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });

const components = fs.readdirSync(componentsPath)
.filter((file) => fs.statSync(path.join(componentsPath, file)).isDirectory());

Promise.all(components.map(component => {
const entry = path.join(componentsPath, component, `${component}.tsx`);
const outfile = path.join(outDir, `${component}.js`);
return esbuild.build({
Comment on lines +14 to +17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add validation for entry file existence.

The script assumes all components follow the naming convention ${component}/${component}.tsx but doesn't validate that the entry file exists before attempting to build it. This could cause the entire build to fail if a component doesn't follow this convention.

Promise.all(components.map(component => {
  const entry = path.join(componentsPath, component, `${component}.tsx`);
+ if (!fs.existsSync(entry)) {
+   console.warn(`Skipping ${component}: Entry file ${entry} not found`);
+   return Promise.resolve();
+ }
  const outfile = path.join(outDir, `${component}.js`);
  return esbuild.build({
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Promise.all(components.map(component => {
const entry = path.join(componentsPath, component, `${component}.tsx`);
const outfile = path.join(outDir, `${component}.js`);
return esbuild.build({
Promise.all(components.map(component => {
const entry = path.join(componentsPath, component, `${component}.tsx`);
if (!fs.existsSync(entry)) {
console.warn(`Skipping ${component}: Entry file ${entry} not found`);
return Promise.resolve();
}
const outfile = path.join(outDir, `${component}.js`);
return esbuild.build({
// ...rest of build options
});
}));
🤖 Prompt for AI Agents
In build-components.cjs around lines 14 to 17, the code assumes the entry file
`${component}/${component}.tsx` exists without validation, risking build failure
if missing. Add a check to verify the existence of the entry file before calling
esbuild.build. If the file does not exist, skip building that component or
handle the error gracefully to prevent the entire build from failing.

entryPoints: [entry],
outfile,
bundle: true,
format: 'esm',
minify: true,
external: ['react', 'react-dom', 'react/jsx-runtime'],
banner: { js: `'use client';` },
sourcemap: false,
// Add more esbuild options as needed
});
})).then(() => {
console.log('All components built with esbuild!');
}).catch((err) => {
console.error(err);
process.exit(1);
});
Loading
Loading