Skip to content

Commit

Permalink
docs: add Universal app changes to documentation
Browse files Browse the repository at this point in the history
* Add details about building the Universal app to the Wiki
* Add README files to the server and Bidi directories to explain
  their purposes
* Remove unused `@angular/tsc-wrapped`
* Add Universal app serve task
  • Loading branch information
CaerusKaru authored and ThomasBurleson committed Feb 22, 2018
1 parent 816f1e6 commit 1cf8a81
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 69 deletions.
1 change: 1 addition & 0 deletions docs/documentation/Developer-Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

* To build the library, run `npm run lib:build`
* To build and serve the demo-app, run `npm run demo:serve`
* To build and serve the Universal app, run `npm run universal:serve`

## Integration within your project

Expand Down
11 changes: 11 additions & 0 deletions docs/documentation/Live-Demos.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,14 @@ responsive demos:
```
npm run demo:serve
```


### Universal (SSR) Demos

A small-scale application that demonstrates how to use Flex Layout on the server. This site is not
available publically, but can be run with the following command:

`npm run universal:serve`

**Note**: This server, unlike the demo-app, does **not** live reload. In order to incorporate build
changes into the universal-app, it will need to be re-built/re-served each time.
124 changes: 58 additions & 66 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"lib:lint": "gulp lint",
"lib:test": "gulp test",
"lib:test:ssr": "gulp test:ssr",
"universal:build": "gulp ci:prerender"
"universal:build": "gulp ci:prerender",
"universal:serve": "gulp universal:serve"
},
"version": "2.0.0-beta.12",
"license": "MIT",
Expand Down Expand Up @@ -47,7 +48,6 @@
"@angular/platform-browser-dynamic": "~5.2.0",
"@angular/platform-server": "~5.2.0",
"@angular/router": "~5.2.0",
"@angular/tsc-wrapped": "^4.4.6",
"@google-cloud/storage": "^1.4.0",
"@types/chalk": "^0.4.31",
"@types/fs-extra": "^4.0.5",
Expand Down
2 changes: 1 addition & 1 deletion src/apps/universal-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/lib/bidi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This directory contains a mirror of the Angular CDK `BidiModule`. It is included in this package to
avoid a direct dependency on `@angular/cdk`, which may be a burden to users.

This package may/may not be removed in upcoming releases, so users are encouraged not to depend on it
explicitly. If there are any issues encountered with the `BidiModule`, please file them in the
Angular Material [repo](https://github.com/angular/material2/issues).
23 changes: 23 additions & 0 deletions src/lib/server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
This entrypoint consolidates the logic for running Flex Layout on the server. Because it uses Node.js
APIs, it must be segmented into the server bundle. This also helps avoid including server code in the
browser bundle.

The main export for this entrypoint, the `FlexLayoutServerModule`, can be imported into a server module
file, e.g. `app.server.module.ts` as follows:

```typescript
import {NgModule} from '@angular/core';
import {FlexLayoutServerModule} from '@angular/flex-layout/server';

@NgModule(({
imports: [
... other imports here
FlexLayoutServerModule,
]
}))
export class AppServerModule {}
```

This module, in addition to handling all of the style processing/rendering before the Angular app is
bootstrapped on the server, also substitutes the version of `MatchMedia` with a server-compatible
implementation called `ServerMatchMedia`.
10 changes: 10 additions & 0 deletions tools/gulp/tasks/universal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const distDir = join(outputDir, 'releases', 'flex-layout');
const tarBall = join(distDir, `angular-flex-layout-${projectVersion}.tgz`);
const appDir = join(packagesDir, 'apps', 'universal-app');

task('universal:serve', sequenceTask(
'prerender',
'prerender:run:server'
));

task('prerender', sequenceTask(
'prerender:pre',
'prerender:build',
Expand Down Expand Up @@ -40,6 +45,11 @@ task('prerender:webpack', execTask(
{cwd: appDir}
));

task('prerender:run:server', execTask(
'node', ['dist/server.js'],
{cwd: appDir, failOnStderr: true}
));

task('prerender:clean', sequenceTask('prerender:clear:deps', 'prerender:clear:dist'));

task('prerender:clear:deps', [], execTask(
Expand Down

0 comments on commit 1cf8a81

Please sign in to comment.