Skip to content
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

Fix nextjs and TS server hot-reload #1183

Merged
merged 2 commits into from
Nov 20, 2024
Merged

Fix nextjs and TS server hot-reload #1183

merged 2 commits into from
Nov 20, 2024

Conversation

aaronvg
Copy link
Contributor

@aaronvg aaronvg commented Nov 20, 2024

Important

Fixes Next.js and TypeScript server hot-reload by changing restartTSServerOnSave default and modifying file timestamps.

  • Behavior:
    • Change restartTSServerOnSave default to false in bamlConfig.ts and package.json.
    • Modify file timestamps in baml_project_manager.ts to trigger file watchers for hot-reload.
  • Imports:
    • Add utimes import from fs in baml_project_manager.ts.

This description was created by Ellipsis for 7c891bc. It will automatically update as commits are pushed.

Copy link

vercel bot commented Nov 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
baml ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 20, 2024 6:16am

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 21068e8 in 20 seconds

More details
  • Looked at 71 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_cDA0b2OJketCnO74


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

try {
// some filewatchers don't trigger unless the file is touched. Creating the new dir alone doesn't work.
// if we remove this, TS will still have the old types, and nextjs will not hot-reload.
g.files.map((f) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Using map here is misleading since the result is not used. Consider using forEach instead for clarity and performance.

Suggested change
g.files.map((f) => {
g.files.forEach((f) => {

@aaronvg aaronvg enabled auto-merge November 20, 2024 06:13
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on 7c891bc in 18 seconds

More details
  • Looked at 21 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_Bxi8RHVYLet6b82v


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

const fpath = path.join(g.output_dir, f.path_in_output_dir)
const currentTime = new Date()
const newTime = new Date(currentTime.getTime() + 100)
utimes(fpath, newTime, newTime, (err) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using fs.promises.utimes for better consistency and error handling.

Suggested change
utimes(fpath, newTime, newTime, (err) => {
await fs.promises.utimes(fpath, newTime, newTime)

@aaronvg aaronvg added this pull request to the merge queue Nov 20, 2024
Merged via the queue into canary with commit 22e6bbb Nov 20, 2024
10 checks passed
@aaronvg aaronvg deleted the fix-ts-hot-reload branch November 20, 2024 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant