This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for hot reload of modified code (#49)
* Make copy of hello-world sample as basis for debuggable hot reloading sample * Update the npm run debug script to watch for file changes * Add VSCode launch configuration for attaching debugger to hot reloadable sample * Add 1 second delay on launch when debugging to allow debugger time to connect * Update README for debuggable hot reload sample * Delete hello-world-with-debuggable-hot-reload sample in favor of making existing samples hot reloadable * Update sample npm run debug scripts to watch for file system changes * Avoid race condition between tsc compiler and nodemod file system watcher * Add 1 second delay on launch when debugging to allow debugger time to connect * Modify VSCode launch configurations to allow debugging while hot reloading * Improve sample READMEs to include debugging instructions * Update VSCode launch config to include both attach and launch configurations * Move concurrently from dependencies to devDependencies * Create separate debug-watch and debug commands * Add attach configs to launch.json while keeping existing attach configs intact * Only need one attach config for debugger * Make copy of hello-world sample as basis for debuggable hot reloading sample * Update the npm run debug script to watch for file changes * Add VSCode launch configuration for attaching debugger to hot reloadable sample * Add 1 second delay on launch when debugging to allow debugger time to connect * Update README for debuggable hot reload sample * Delete hello-world-with-debuggable-hot-reload sample in favor of making existing samples hot reloadable * Update sample npm run debug scripts to watch for file system changes * Avoid race condition between tsc compiler and nodemod file system watcher * Add 1 second delay on launch when debugging to allow debugger time to connect * Modify VSCode launch configurations to allow debugging while hot reloading * Improve sample READMEs to include debugging instructions * Update VSCode launch config to include both attach and launch configurations * Move concurrently from dependencies to devDependencies * Create separate debug-watch and debug commands * Add attach configs to launch.json while keeping existing attach configs intact * Only need one attach config for debugger * Tweaks to hot reload and docs * apostrophe * Update package-lock.json * Remove accidentally added eslint-plugin-header package * Update package-lock.json files * Remove startup delay from app.ts * Add startup delay to other samples. * Fix line endings. * Remove opinionated text. * Propagate doc updates to other samples. Co-authored-by: Eric Anderson <[email protected]>
- Loading branch information
1 parent
470417e
commit 5be14ed
Showing
23 changed files
with
6,400 additions
and
1,333 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -1,15 +1,54 @@ | ||
Shows a text that animates when highlighting or clicking on a cube. | ||
|
||
## Editing | ||
## Setup | ||
|
||
* Open this folder in VSCode. | ||
* Open a command prompt to this sample's folder and run `npm install`. Keep the command prompt open if you wish to follow the command-oriented instructions that follow. | ||
* Open the root folder of this repo in VSCode if you wish to follow the VSCode-oriented instructions. | ||
|
||
## Building | ||
## Build | ||
|
||
* From inside VSCode: `Shift+Ctrl+B` | ||
* From command line: `npm run build` | ||
* Command line: `npm run build`. | ||
* VSCode: `Shift+Ctrl+B`, then select 'build samples/hello-world'. | ||
|
||
## Running | ||
## Run | ||
|
||
* From inside VSCode: `F5` | ||
* From command line: `npm start` | ||
* Command line: `npm start`. | ||
* VSCode: Switch to the 'Run' tab (`Ctrl+Shift+D` will open it), select 'Launch hello-world project' from the dropdown at the top, and then `F5` to start it. | ||
|
||
MRE apps are NodeJS servers. They operate akin to a web server. When you start your MRE, it won't do much until you connect to it from a client application like AltspaceVR or the MRETestBed. | ||
|
||
## Test in [AltspaceVR](https://altvr.com) | ||
|
||
* Download [AltspaceVR](https://altvr.com) and create an account. | ||
* Launch the application and sign in. You'll start in your "home space". | ||
* Open the World Editor (only available if you indicate you want to participate in the [Early Access Program](https://altvr.com/early-access-program/) in your AltspaceVR settings). | ||
* Add a `Basics` / `SDK App` object with a Target URI of `ws://127.0.0.1:3901`. | ||
* See the the app appear in your space. | ||
|
||
## Test in Unity using the [MRETestBed](https://www.github.com/mixed-reality-extension-sdk-samples) | ||
|
||
* Install [Unity](https://unity3d.com/get-unity/download), version 2019.2.12f1 or later. | ||
* Clone the [MRE Unity repo](https://github.com/microsoft/mixed-reality-extension-unity). | ||
* Open the 'MRETestBed' Unity project. | ||
* Select the 'Standalone' scene. This scene is preconfigured to connect to your MRE running locally. | ||
* Start the Unity scene, and see the app appear. | ||
|
||
## Advanced: Debug with Hot-Reload | ||
|
||
Whether developing an MRE or another kind of app, an efficient dev/test loop is essential. Devs familiar with making browser-based apps will be familiar with webpack's notion of "hot reload", that is, automatically applying changes as they're made without the need to explicitly stop/rebuild/restart your app. NodeJS apps can do this too. | ||
|
||
This setup requires launching the app from a terminal. VSCode has a built-in terminal, or you can open a separate command prompt. | ||
|
||
### Start the MRE with hot-reload enabled | ||
|
||
1. In the terminal, in this project's folder, run: `npm run debug-watch`. This will build and start the MRE. The `debug-watch` task continues to run in the background, watching for code changes. It will rebuild and restart the app whenever files are modified. | ||
2. In VSCode, press `Ctrl+Shift+D` to open the 'Run' tab, select 'Attach to running project' from the drop down at the top, then press `F5` to attach the VSCode debugger. This step isn't required, but allows you to set breakpoints and debug MRE execution. | ||
|
||
### See hot-reload in action | ||
|
||
Once you have your MRE up and running, and you've successfully spawned an instance in AltspaceVR or another supported platform, it is time to make some code changes and see hot reload in action: | ||
|
||
* In VSCode, open `samples/hello-world/app.ts`. | ||
* In the `App.started()` method, find the line that reads `contents: "Hello World!",` and change the string to `"Hello Brave New World!"`. | ||
* Save the file. | ||
* Watch how the changes to your code are automatically detected and reloaded. The text in your app should change to `"Hello Brave New World!"` |
Oops, something went wrong.