Skip to content

Abstract ReactDevelopmentServerMiddleware to DevelopmentServerMiddleware for other NPM Web Servers #7452

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

Closed

Conversation

WilliamABradley
Copy link

Summary of the changes (Less than 80 chars)
Abstracted ReactDevelopmentServerMiddleware into DevelopmentServerMiddleware, obsoleted old namespace, Added Generic UseDevelopmentServer and Vue UseVueDevelopmentServer.

This opens up SpaExtensions for Vue.js as well as other npm/webpack development servers for serving UI Frameworks.

This can be used to make a Vue.js Visual Studio Template.

…dleware, obsoleted old namespace, Added Generic UseDevelopmentServer and Vue UseVueDevelopmentServer.
@Tratcher Tratcher requested review from SteveSandersonMS and removed request for Tratcher February 11, 2019 16:48
@Eilon Eilon added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Feb 11, 2019
@WilliamABradley
Copy link
Author

@SteveSandersonMS Any news?


var envVars = new Dictionary<string, string>
{
{ "PORT", portNumber.ToString() },
{ "BROWSER", "none" }, // We don't want create-react-app to open its own extra browser window pointing to the internal dev server port
{ "BROWSER", "none" }, // We don't want the dev server to open its own extra browser window pointing to the internal dev server port
Copy link
Member

@SteveSandersonMS SteveSandersonMS Feb 25, 2019

Choose a reason for hiding this comment

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

I would have thought this shouldn't be here, as it's specific to React. Could the method take a dictionary of environment variables as a parameter instead?

this ISpaBuilder spaBuilder,
string npmScript,
string waitText,
string serverName = "App")
Copy link
Member

@SteveSandersonMS SteveSandersonMS Feb 25, 2019

Choose a reason for hiding this comment

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

To me, these APIs feel extremely over-specialized. What if the "ready" signal isn't some static text you can look for? What if the way to start it isn't running an NPM script?

What I'd expect instead would be to decompose this into lower-level building blocks, e.g.:

  • Some method for starting an NPM script and getting back the Process
  • Some method for transforming the standard output stream from a Process into an async-enumerable-of-string
  • UseReactDevelopmentServer and UseAngularCli methods that call the "start NPM task" method, then awaits until it outputs the expected "I'm running now" string. These can each contain their own instructions to output text like "Starting Angular CLI server...", so no need to make these into parameters on something else.

What do you think - could this be an improvement?

/// </summary>
/// <param name="spaBuilder">The <see cref="ISpaBuilder"/>.</param>
/// <param name="npmScript">The name of the script in your package.json file that launches the vue-cli-service server.</param>
public static void UseVueDevelopmentServer(
Copy link
Member

@SteveSandersonMS SteveSandersonMS Feb 25, 2019

Choose a reason for hiding this comment

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

I appreciate that this adds a feature, but we haven't announced any plan to build in support for Vue-specific things. Previously, we explicitly stepped away from doing that, so we could focus on the two most demanded third-party SPA frameworks (Angular and React).

If we were to change this plan (and it might be that, for the time being, it doesn't change) that would be a decision for @danroth27.

@@ -21,23 +22,12 @@ public static class ReactDevelopmentServerMiddlewareExtensions
/// </summary>
/// <param name="spaBuilder">The <see cref="ISpaBuilder"/>.</param>
/// <param name="npmScript">The name of the script in your package.json file that launches the create-react-app server.</param>
[Obsolete("Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer.ReactDevelopmentServerMiddlewareExtensions.UseReactDevelopmentServer is deprecated, please use Microsoft.AspNetCore.SpaServices.DevelopmentServer.DevelopmentServerMiddlewareExtensions.UseReactDevelopmentServer instead.")]
Copy link
Member

Choose a reason for hiding this comment

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

Rather than obsoleting this, could the new logic go here instead of making a new extension method for it?

},
{
"Kind": "Method",
"Name": "UseVueDevelopmentServer",
Copy link
Member

@SteveSandersonMS SteveSandersonMS Feb 25, 2019

Choose a reason for hiding this comment

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

As per the comment above, this should only be added after an explicit product decision (which might not happen!)

Copy link
Member

@SteveSandersonMS SteveSandersonMS left a comment

Choose a reason for hiding this comment

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

Hope you don't mind these suggestions!

@ryanbrandenburg, are you interested in taking over on this PR? No worries if not - I'm happy to continue the conversation here.

@ryanbrandenburg
Copy link
Contributor

@SteveSandersonMS I won't have useful knowledge here until I've been brought up to speed on the whole area, so it's probably best if you stick with it for now.

@mkArtakMSFT
Copy link
Member

@SteveSandersonMS , @ryanbrandenburg what is pending here?

@ryanbrandenburg
Copy link
Contributor

A response to @SteveSandersonMS's request for changes. It'll also need to rebase to solve that conflict.

@elken
Copy link

elken commented Jul 4, 2019

I've also requested this feature before (#8024), would be happy to attempt to implement @SteveSandersonMS's changes?

EDIT: #11897

elken pushed a commit to elken/AspNetCore that referenced this pull request Jul 4, 2019
- Removed VueDevelopmentServer
- Added Dictionary for arguments to DevelopmentServer
- Unobseleted ReactDevelopmentServer
@SteveSandersonMS
Copy link
Member

Closing as per conversation in #11897

@mkArtakMSFT mkArtakMSFT added the tell-mode Indicates a PR which is being merged during tell-mode label Jul 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates tell-mode Indicates a PR which is being merged during tell-mode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants