-
-
Notifications
You must be signed in to change notification settings - Fork 53
new esbuild and removal of prebuild running twice #1214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6685cae
new esbuild and removal of prebuild running twice
GoldGroove06 5465d51
moving esbuild to dev dependencies
GoldGroove06 123232d
types checking added
GoldGroove06 b1e4684
both scripts can now co exisit
GoldGroove06 4e9213f
Merge branch 'main' into build-improvements
GoldGroove06 18ee0c0
workflow updated
GoldGroove06 853d93e
Merge branch 'build-improvements' of https://github.com/rad-ui/ui int…
GoldGroove06 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,4 +24,4 @@ jobs: | |
| run: npm ci | ||
|
|
||
| - name: Build | ||
| run: npm run build | ||
| run: npm run build:rollup | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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({ | ||
| 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); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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}.tsxbut 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
🤖 Prompt for AI Agents