Feature: Watch mode without dev server #1427
Closed
rschristian wants to merge 17 commits intopreactjs:masterfrom
Closed
Feature: Watch mode without dev server #1427rschristian wants to merge 17 commits intopreactjs:masterfrom
rschristian wants to merge 17 commits intopreactjs:masterfrom
Conversation
🦋 Changeset is good to goLatest commit: 95e36a9 We got this. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Member
Author
|
A few changes are purely code-style based that my IDE caught. I figure I won't revert them for now as they do look to be correct changes, but I can undo this if it makes the PR too messy. |
Member
Author
|
I'd need to come back to look at this again. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What kind of change does this PR introduce?
Feature
Did you add tests for your changes?
Yes. I added a test under
watch.test.jsthat will run the file watcher and check to see if the built output is updated after a change occurs to the source. I figure this approach is simpler than the alternatives and still ensures the functionality works. So long as the built output changes the feature should be fine. I don't think we need a browser test.Summary
This builds upon #1264 which leads back to & would close #1248.
Currently, the experience for developing SSR apps using the Preact CLI isn't great. To produce a bundle that can be used a developer needs to run the full production build and then rerun it on every change. This is slow and un-automated.
A solution, as pointed out by @oliverstr, is to provide an option to disable the dev server in
watchmode. Any changes to the source would have the CLI rebuild and developers can consume the build in any way that they please.@oliverstr's PR for implementing this feature (#1264) has been untouched since June 29th so I figure at this point it is fair to step in and try to complete. His PR had a few issues, besides being behind the current head, namely, it would not clear the
build/directory, leading to a large build up of temporary files, it ignored changes tosrc/*by default, and it could not handle CSS imports without wrapping them in a window check (if (typeof window !== "undefined") { ... }). I have fixed all three of these issues and a few more that popped up along the way to finish off his feature.You can use the following repo to try this out, though you'll need to bring your own CLI copy with linking or relative paths. Simple server set up with Polka and Nodemon. Simply run
yarn serve:devin one terminal window andyarn servein another.serve:devstarts the CLI watch mode,servestarts Polka with Nodemon. Nothing fancy.ryanchristian4427/preact-cli-watch-without-devserver
Does this PR introduce a breaking change?
No breaking changes. This feature is behind a flag.