GithubHelp home page GithubHelp logo

madskristensen / javascriptservices Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aspnet/javascriptservices

0.0 3.0 0.0 6.91 MB

Microsoft ASP.NET Core JavaScript Services

License: Other

Batchfile 0.05% PowerShell 0.39% Shell 0.25% C# 39.08% JavaScript 19.56% TypeScript 34.91% CSS 1.99% HTML 3.77%

javascriptservices's Introduction

JavaScriptServices

AppVeyor: AppVeyor

This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the Home repo.

What is this?

JavaScriptServices is a set of client-side technologies for ASP.NET Core. It provides infrastructure that you'll find useful if you:

  • Use Angular 2 / React / Vue / Aurelia / Knockout / etc.
  • Build your client-side resources using Webpack.
  • Execute JavaScript on the server at runtime.

Read Building Single Page Applications on ASP.NET Core with JavaScriptServices for more details.

This repo contains:

  • A set of NuGet/NPM packages that implement functionality for:
    • Invoking arbitrary NPM packages at runtime from .NET code (docs)
    • Server-side prerendering of SPA components (docs)
    • Webpack dev middleware (docs)
    • Hot module replacement (HMR) (docs)
    • Server-side and client-side routing integration (docs)
    • Server-side and client-side validation integration
    • "Lazy loading" for Knockout apps
  • A Yeoman generator that creates preconfigured app starting points (guide)
  • Samples and docs

It's cross-platform (Windows, Linux, or macOS) and works with .NET Core 1.0.1 or later.

Creating new applications

If you want to build a brand-new ASP.NET Core app that uses Angular 2 / React / Knockout on the client, consider starting with the aspnetcore-spa generator. This lets you choose your client-side framework. It generates a starting point that includes applicable features such as Webpack dev middleware, server-side prerendering, and efficient production builds. It's much easier than configuring everything to work together manually!

To do this, install Yeoman and these generator templates:

npm install -g yo generator-aspnetcore-spa

Generate your new application starting point:

cd some-empty-directory
yo aspnetcore-spa

Once the generator has run and restored all the dependencies, you can start up your new ASP.NET Core SPA:

dotnet run 

For a more detailed walkthrough, see getting started with the aspnetcore-spa generator.

Adding to existing applications

If you have an existing ASP.NET Core application, or if you just want to use the underlying JavaScriptServices packages directly, you can install these packages using NuGet and NPM:

  • Microsoft.AspNetCore.NodeServices
    • This provides a fast and robust way for .NET code to run JavaScript on the server inside a Node.js environment. You can use this to consume arbitrary functionality from NPM packages at runtime in your ASP.NET Core app.
    • Most applications developers don't need to use this directly, but you can do so if you want to implement your own functionality that involves calling Node.js code from .NET at runtime.
    • Find documentation and usage examples here.
  • Microsoft.AspNetCore.SpaServices
    • This provides infrastructure that's generally useful when building Single Page Applications (SPAs) with technologies such as Angular 2 or React (for example, server-side prerendering and webpack middleware). Internally, it uses the NodeServices package to implement its features.
    • Find documentation and usage examples here.
  • Microsoft.AspNetCore.AngularServices
    • This builds on the SpaServices package and includes features specific to Angular 2. Currently, this includes validation helpers.
    • The code is here. You'll find a usage example for the validation helper here.

There was previously a Microsoft.AspNetCore.ReactServices but this is not currently needed - all applicable functionality is in Microsoft.AspNetCore.SpaServices, because it's sufficiently general. We might add a new Microsoft.AspNetCore.ReactServices package in the future if new React-specific requirements emerge.

If you want to build a helper library for some other SPA framework, you can do so by taking a dependency on Microsoft.AspNetCore.SpaServices and wrapping its functionality in whatever way is most useful for your SPA framework.

Samples and templates

Inside this repo, the templates directory contains the application starting points that the aspnetcore-spa generator emits. You can clone this repo and run those applications directly. But it's easier to use the Yeoman tool to run the generator.

The samples directory contains examples of:

  • Using the JavaScript services family of packages with Angular 2 and React.
  • A standalone NodeServices usage for runtime code transpilation and image processing.

To run the samples:

  • Clone this repo
  • At the repo's root directory (the one containing src, samples, etc.), run dotnet restore
  • Change directory to the sample you want to run (for example, cd samples/angular/MusicStore)
  • Restore Node dependencies by running npm install
    • If you're trying to run the Angular 2 "Music Store" sample, then also run gulp (which you need to have installed globally). None of the other samples require this.
  • Run the application (dotnet run)
  • Browse to http://localhost:5000

Contributing

If you're interested in contributing to the various packages, samples, and project templates in this repo, that's great! You can run the code in this repo as follows:

  • Clone the repo
  • Run dotnet restore at the repo root dir
  • Go to whatever sample or template you want to run (for example, cd templates/Angular2Spa)
  • Restore NPM dependencies (run npm install)
  • If the sample/template you're trying to run has a file called webpack.config.vendor.js at its root, run webpack --config webpack.config.vendor.js. It it has a file called webpack.config.js, run webpack (no args). You might need to install webpack first, by running npm install -g webpack.
  • Launch it (dotnet run)

If you're planning to submit a pull request, and if it's more than a trivial fix (for example, for a typo), it's usually a good idea first to file an issue describing what you're proposing to do and how it will work. Then you can find out if it's likely that such a pull request will be accepted, and how it fits into wider ongoing plans.

javascriptservices's People

Contributors

stevesandersonms avatar laskoviymishka avatar markpieszak avatar eilon avatar gregbty avatar henkmollema avatar mattvperry avatar natemcmaster avatar pranavkm avatar rick-anderson avatar pauldotknopf avatar nicemd avatar thoughtentity avatar davidfowl avatar aidansteele avatar aaronpowell avatar pglazkov avatar rmja avatar rjperes avatar scottaddie avatar skamlet avatar stephtr avatar sebastienros avatar novascreen avatar tobiasr avatar wrathza avatar ferrx avatar kmkatsma avatar peterlazzarino avatar thunder7553 avatar

Watchers

James Cloos avatar Mads Kristensen avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.