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

feat(cli): update a touchfile upon successful (re)build in watch mode #4307

Closed
wants to merge 1 commit into from
Closed

feat(cli): update a touchfile upon successful (re)build in watch mode #4307

wants to merge 1 commit into from

Conversation

andrewbrey
Copy link
Contributor

When in watch mode with the remix cli we do incremental rebuilds of changed files, but unfortunately there is no way for external processes (e.g. a dev server) to know that a (re)build has successfully finished other than by watching the build output directories, which is a lot of open file descriptors just to know something that the remix cli already knows.

This PR adds a very simple signal, in the form of a well-known file saved to the configured cache directory, that external processes can use as a simple mechanism to know concretely that Remix is done rebuilding files.

My ideal solution for this use case would be something more like callbacks supplied via the remix.config.js, e.g.

// remix.config.js

module.exports = {
	// ... other configuration
	watchFirstBuildCallback: () => {
		// do stuff on first build, e.g. start a nodemon process for my `express` server...
	},
	watchRebuildCallback: () => {
		// do stuff on successful rebuilds, e.g. purge my express server `require` cache, or just reboot it...
	}
}

but that is a bit bigger in scope, so I thought it would be useful to just start small with this 😄

@changeset-bot
Copy link

changeset-bot bot commented Oct 2, 2022

⚠️ No Changeset found

Latest commit: 2df0e92

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pcattori
Copy link
Contributor

One workaround could be to only watch the assets manifest and see if the hash in there changes. If you need to watch for server builds, then you only need to watch build/index.js. So that would be an effective way to detect changes by only watching for changes in two files.

@pcattori
Copy link
Contributor

I'm also looking into a Node API for the Remix compiler so that you could call watch yourself with the appropriate callbacks (E.g. onRebuildSuccess or something). I think that would ultimately be better for most use-cases than relying on sentinel file watching, though we can certainly make that doable too.

@pcattori
Copy link
Contributor

Related to #5133

@andrewbrey andrewbrey closed this by deleting the head repository Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants