Giter Site home page Giter Site logo

Comments (23)

MarkPieszak avatar MarkPieszak commented on May 22, 2024 2

I'm actually not familiar with Edge, but basically how it's done from the .NET Core side of things is:

.NET aware Tag, in this case an attribute (asp-prerender)
This can be passed a few things, webpack config, data, and the bootstrap server file location.

It in turn invokes a Node process that simultaneously handles webpack dev server
& also
serializes the app with Universal passing the needed server-side info (url, origin for example) to the JS/TS file that ends up calling Universal to serialize the app, passing it back as an html string.

That's the general big picture, there's a few more detailed things about it, but that's jist! @Nicholas-Westby

from universal.

0x-r4bbit avatar 0x-r4bbit commented on May 22, 2024

@gdi2290 Can we add nickel.rs to the list? http://nickel.rs /cc @cburgdorf

from universal.

cburgdorf avatar cburgdorf commented on May 22, 2024

I'm happy to help with an implementation for Nickel but I'm not sure how feasible it is. I guess this relies on offloading some of the work to a serverside JS renderer (https://github.com/gdi2290/play-angular2/blob/master/app/controllers/Application.scala#L66)

from universal.

PatrickJS avatar PatrickJS commented on May 22, 2024

I know someone in the Rust community so I can see if he can work with you guys on it

from universal.

PatrickJS avatar PatrickJS commented on May 22, 2024

The idea here is to have a baseline way of rendering on the server with the quick and dirty way being the cli. The preferred method would be compiling Angular 2 into the language you're working on which means creating you're own facades

from universal.

danicomas avatar danicomas commented on May 22, 2024

@gdi2290 add Microsoft IIS too.

from universal.

PatrickJS avatar PatrickJS commented on May 22, 2024

@danicomas Microsoft IIS might take more work unless we have someone who knows how to run JavaScript in that environment

from universal.

flyingmutant avatar flyingmutant commented on May 22, 2024

For Go, may I suggest going with raw net/http — which would be a solution that every Go project can use.

from universal.

PatrickJS avatar PatrickJS commented on May 22, 2024

closing for now until we have more time or if there is more interest in the community to help out

from universal.

alukach avatar alukach commented on May 22, 2024

I'd be interested to hear what the steps for moving these types of things forward would be. Is there a common pattern to apply to most of these languages?

from universal.

Nicholas-Westby avatar Nicholas-Westby commented on May 22, 2024

Just a heads up that I'm now researching how to accomplish server side rendering using Edge.js in ASP.NET MVC: https://github.com/Nicholas-Westby/angular-2-lab

I also have a Stack Overflow question in relation to this: http://stackoverflow.com/questions/40625354/server-side-rendering-angular-2-in-asp-net-with-edge-js

If anybody has any sort of guidance, that would be useful.

from universal.

Nicholas-Westby avatar Nicholas-Westby commented on May 22, 2024

Thanks for the quick reply, @MarkPieszak! I was actually poking around in your repo trying to figure things out. Could you point me to where the tag helpers are defined (asp-prerender-module, asp-prerender-webpack-config, asp-prerender-data)? That might help me understand things a bit better.

By the way, I'm essentially trying to use Edge.js to invoke Node from C# (sounds like you do something similar). My intention is to have all the compilation/minification/tree shaking/etc take place during compile time, then at runtime use Edge.js/Node to perform server side rendering to markup. I'm not quite sure if I fully understand, but it sounds like you may be essentially combining the two processes (compile and render) into a single tool. For my purposes, just seeing how you are doing that would be of great use.

from universal.

Nicholas-Westby avatar Nicholas-Westby commented on May 22, 2024

FYI, I'm going to abandon my efforts to get Angular rendering on the server side in ASP.NET. I've spent about 3 days on this so far and have been running into too many issues. If anybody else wants to resume where I left off, my latest attempt is in the "part-deux" branch of my "angular-2-lab": https://github.com/Nicholas-Westby/angular-2-lab/tree/part-deux

from universal.

MarkPieszak avatar MarkPieszak commented on May 22, 2024

What issues were you running into? I can see if it's possible to get .NET 4.6 to call Node the way we need to.

from universal.

Nicholas-Westby avatar Nicholas-Westby commented on May 22, 2024

I solved a bunch of them today. This commit offers a little guidance on what next steps might be: Nicholas-Westby/angular-2-lab@5e9c14e

In short, I got the code to browserify some JavaScript (that was itself using Node.js modules), compile some TypeScript to JavaScript, coordinate between the browserified JavaScript and the compiled TypeScript, and finally call that JavaScript from ASP.NET MVC (using .NET 4.5.2 and Edge.js).

That all works fine and dandy. The thing I tried to tackle after that was to get the TypeScript code from ASP.NET Core Angular Universal. I think I got that compiling OK now (maybe... it seems to fluctuate with the weather).

As indicated in the above commit, the next goal is to call some function from my main TypeScript file that renders some Angular into HTML. I believe this may be done by calling into bootstrap-server.ts, but I haven't had a chance to try it yet.

If you want to give it a go, just follow the instructions to get things compiled, then open the solution in Visual Studio and run. You should see this:

angular-2-experiment

Note that the message you see does not involve any Angular. It just confirms that I'm seeing some code derived from both NPM modules and from TypeScript.

from universal.

Nicholas-Westby avatar Nicholas-Westby commented on May 22, 2024

Oops, looks like I missed a TypeScript file in that commit from above. Here's the commit that fixes that: Nicholas-Westby/angular-2-lab@0f9f830

from universal.

Nicholas-Westby avatar Nicholas-Westby commented on May 22, 2024

Here's a new issue in my latest commit: Nicholas-Westby/angular-2-lab@9fab365

Browserify seems to be choking (I'm trying to run browserify on compiled TypeScript):

browserify-error

I was seeming to make progress by avoiding the paths defined in tsconfig.json, until I hit this. Maybe I shouldn't be running browserify? Is this one of the reasons Webpack is used?

from universal.

MarkPieszak avatar MarkPieszak commented on May 22, 2024

Is platform-browser-dynamic in your node_modules?

from universal.

Nicholas-Westby avatar Nicholas-Westby commented on May 22, 2024

Looks like it wasn't. Attempting to adjust my package.json now to more closely match the package.json here: https://github.com/MarkPieszak/aspnetcore-angular2-universal/blob/master/package.json

from universal.

Nicholas-Westby avatar Nicholas-Westby commented on May 22, 2024

Now that I updated the package.json, I get a new error (node_modules/rxjs/observable/PairsObservable.d.ts(1,1): error TS2688: Cannot find type definition file for 'chai'):

rxjs-error

from universal.

MarkPieszak avatar MarkPieszak commented on May 22, 2024

Add it in your devDepdencies, or (I believe) the newest version of RxJs fixes it. I have the @types/chai in there for now.

"@types/chai": "^3.4.34", 

from universal.

Nicholas-Westby avatar Nicholas-Westby commented on May 22, 2024

Thanks, that seems to have fixed that error. Here's the new error I'm seeing:

zone-error

Strange that it's using underscores. I'd expect that to say require('http-client').

from universal.

angular-automatic-lock-bot avatar angular-automatic-lock-bot commented on May 22, 2024

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

from universal.

Related Issues (20)

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.