Comments (23)
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.
@gdi2290 Can we add nickel.rs to the list? http://nickel.rs /cc @cburgdorf
from universal.
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.
I know someone in the Rust community so I can see if he can work with you guys on it
from universal.
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.
@gdi2290 add Microsoft IIS too.
from universal.
@danicomas Microsoft IIS might take more work unless we have someone who knows how to run JavaScript in that environment
from universal.
For Go, may I suggest going with raw net/http
— which would be a solution that every Go project can use.
from universal.
closing for now until we have more time or if there is more interest in the community to help out
from universal.
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.
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.
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.
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.
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.
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:
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.
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.
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):
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.
Is platform-browser-dynamic in your node_modules?
from universal.
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.
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'
):
from universal.
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.
Thanks, that seems to have fixed that error. Here's the new error I'm seeing:
Strange that it's using underscores. I'd expect that to say require('http-client')
.
from universal.
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)
- prerendering makes no name folder on MacOS HOT 2
- Can not set a fixed port for ssr-dev-server HOT 3
- Non-english characters are converted into html entities in browser view-source for Angular v16 Universal HOT 1
- Inability to send requests to assets using APP_BASE_HREFf in an Angular unviersal application HOT 2
- Unable to add the nguniversal/express-engine HOT 6
- Cannot change port for dev:ssr HOT 4
- build error HOT 2
- Angular universal & cookies based auth. HOT 5
- Passenger error on every page except home HOT 4
- Setup dynamic build options for prerendering HOT 2
- How to stop server side prerender for CSS HOT 2
- "TypeError: link.prev?.setAttribute is not a function" upon rendering any page with "ngCspNonce" set. HOT 1
- Unable to set extraProviders for prerender builder. HOT 2
- SSR on change detection in same page or same route. HOT 2
- Angular14 ssr page document loads very slow HOT 2
- Module '"@angular/platform-browser"' has no exported member 'provideClientHydration'. HOT 2
- Angular Universal build always adds the app.component tags HOT 4
- Weird behavior of SSR with i18n HOT 2
- Issue when debug @nguniversal/builders:ssr-dev-server HOT 2
- Anguar 14 | Angular Universal | this._removeListenerFns.pop(...) is not a function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from universal.