Comments (7)
Also looking at the source of angular-rendering.js
there doesn't seem to be support for using preboot, i.e renderToStringWithPreboot
rather than renderToString
.
from javascriptservices.
That's correct - thanks for bringing up these points.
If you have any time to work on adding this functionality I'd be pleased to take a pull request. Otherwise I'll aim to get to it at some point, though there are lots of other jobs higher up on my list so there's no ETA.
from javascriptservices.
I'll take a stab at adding preboot support. That should be relatively straight forward. Workers might be slightly trickier but I have some ideas.
from javascriptservices.
I've got preboot mostly working. However I notice that in the angular2spa template you're requiring the client code to do the server side render. If that's the model you're going for then it makes more sense for the other of the client code to be responsible. That way AngularServices doesn't have to be changed every time angular2 changes.
In any case I changed renderToString as follows:
renderToString: function(callback, options) {
try {
var component = findAngularComponent(options);
var serverBindings = [
ngRouter.ROUTER_BINDINGS,
ngUniversal.HTTP_PROVIDERS,
// TODO: BASE_URL has been replaced by REQUEST_URL in [email protected]
ngCore.provide(ngUniversal.BASE_URL, { useValue: options.requestUrl }),
ngCore.provide(ngRouter.APP_BASE_HREF, { useValue: '/' }),
ngUniversal.SERVER_LOCATION_PROVIDERS
];
return (options.preboot
? ngUniversalRender.renderToStringWithPreboot(component, serverBindings, {
freeze: { name: 'spinner' },
replay: 'rerender',
buffer: true,
debug: true,
uglify: false,
})
: ngUniversalRender.renderToString(component, serverBindings)).then(
function(successValue) { callback(null, successValue); },
function(errorValue) { callback(errorValue); }
);
} catch (synchronousException) {
callback(synchronousException);
}
}
As you can see not much needs to change to support preboot. In your Angular2Spa template, for instance, just call ngUniversalRender.renderToStringWithPreboot
as illustrated above.
In any case I can create PR for the renderToString change (and associated taghelper attribute to enable preboot) or you could opt for the option currently illustrated in the template Angular2Spa template where each framework provides their own prerender code. I like the latter as it makes implementing web workers much easier.
from javascriptservices.
Thanks for looking into this.
or you could opt for the option currently illustrated in the template Angular2Spa template where each framework provides their own prerender code. I like the latter as it makes implementing web workers much easier.
Yes, I agree, and that is the model I'm leaning towards. I'll remove the older asp-ng2-prerender-module
tag helper in favour of the newer and more flexible asp-prerender-module
one soon.
So I guess, as per your research, there isn't much we need to do here, as the developer can control their use of preboot by editing the boot-server.ts
file in whatever way they want.
If you get any insight into what we should do for web workers (if anything) please let me know.
from javascriptservices.
Yea the asp-prerender-module
option is much more flexible. Preboot works with zero modification, though I did modify the asp-ng2-prerender-module
to support preboot anyway.
For workers, as it turns out there isn't much to do there either. You go from having one entry file to multiple (one for the UI thread and the other for the web worker which is loaded asynchoronously). Pre-rendering works as it does now and I was able to get that working.
The only thing I had problems with was using the webpack dev server as there wasn't an obvious way of setting the path to the webpack.config.js file like you can do when setting up the prerendering tag helper. Could just be user error on my part.
To demonstrate web worker support in the template you could do something like i've done here (though mine's not finished due to time constraints but the basic idea is there.
In terms of tooling to support web workers, the only thing I can think of is item templates in VS for bootstrap files.
Slightly off-topic, I was watching your NodeServices presentation at NgConf, I think, in London. Was very well done.
from javascriptservices.
I'm just tidying up some issues and it looks like it would be reasonable to close this one, unless anyone has any specific objections.
The preboot issue is resolved since we migrated to the asp-prerender-module
helper (you can just pass preboot: true
).
About web workers, this is also now entirely under the control of the developer since the asp-prerender-module
approach lets you implement whatever server-side boot code you want. We probably won't use web workers in the default Angular2Spa template because it would increase complexity and make it hard to understand for newcomers. Or if anyone thinks it's really important and can be done simply please let me know.
from javascriptservices.
Related Issues (20)
- package reinstall HOT 2
- s
- Uncaught ReferenceError: vendor_ is not defined when using DllReferencePlugin HOT 5
- aspnet-webpack support? HOT 2
- Module not found : error : Can't resolve './../$$_gendir/ClientApp/app/app.browser.module.ngfactory' HOT 1
- Buffer is deprecated in Node 10
- Expose some of the internal classes HOT 1
- React+Redux Template does not compile with --strict HOT 1
- JavaScriptServices vs Templating github HOT 1
- SSR with Vue requires javascript enabled? HOT 2
- What happened to the template in .NET Core 2.1?
- Ignore
- Delay in domain-task Promise Resolution when Server Side Rendering HOT 1
- How to publish the javascriptservices project (asp.netcore rest api project which uses node api) to IIS 8. The application not wroking after publishing to IIS HOT 2
- UseProxyToSpaDevelopmentServer doesn't auto-refresh browser using an Aurelia ClientApp with HMR HOT 3
- Release date for angular 6 template ? HOT 1
- Using Angular template - all routes are directing to Angular app directly, unable to implement ASP.NET /API route HOT 2
- Files being written to disk with WebpackDevMiddleware HOT 1
- The request matched multiple endpoints HOT 1
- Need clarification
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 javascriptservices.