Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

chore(examples): migrate SSR example to angular 7 #471

Merged
merged 6 commits into from
Feb 22, 2019
Merged

chore(examples): migrate SSR example to angular 7 #471

merged 6 commits into from
Feb 22, 2019

Conversation

tkrugg
Copy link
Contributor

@tkrugg tkrugg commented Feb 20, 2019

Summary
We used to have a hard time getting SSR to work ever since Angular 6 came out.
I've updated the project to @angular/* and @nguniversal ^7. It seems better.

Result

I'll have to do the same thing again with Angular 6 just to check if we can completely remove any compatibility caveat from our docs, but I won't be making a PR for that

closes #379

@tkrugg tkrugg added the Do not merge Not ready to be merged label Feb 20, 2019
@@ -0,0 +1,141 @@
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the new .angular-cli.json introduced by the migration to @angular/cli@^7

@algobot
Copy link

algobot commented Feb 20, 2019

Deploy preview for angular-instantsearch ready!

Built with commit 413c32d

https://deploy-preview-471--angular-instantsearch.netlify.com

@@ -39,7 +39,6 @@

/** Evergreen browsers require these. **/
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was removed to the migration.
It's is expected when upgrading to v7

@@ -1 +1 @@
export const VERSION = "2.2.1";
export const VERSION = '2.2.1';
Copy link
Contributor

@Haroenv Haroenv Feb 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change seems unrelated (but still good)

Copy link
Contributor Author

@tkrugg tkrugg Feb 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's just prettier doing its thing

@@ -1,6 +1,7 @@
{
"compileOnSave": false,
"compilerOptions": {
"importHelpers": true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new requirement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is another result of the migration.
In package.json you'll also notice a new dependency [tslib].(https://www.npmjs.com/package/tslib) introduced by the migrator (I think it's optional)
This compile option is a usage requirement of this lib.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep it look like it's the same purpose than Babel runtime.

@samouss
Copy link
Contributor

samouss commented Feb 20, 2019

@tkrugg rather than "WIP xxx" use the draft pull request!

screenshot 2019-02-20 at 12 41 47

@tkrugg tkrugg changed the title WIP chore(examples): migrate SSR example to angular 7 chore(examples): migrate SSR example to angular 7 Feb 20, 2019
@tkrugg tkrugg removed the Do not merge Not ready to be merged label Feb 20, 2019
@@ -1,6 +1,6 @@
import 'zone.js/dist/zone-node';
import 'reflect-metadata';
import { renderModuleFactory } from '@angular/platform-server';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was unused

@@ -4,25 +4,24 @@ const path = require('path');
const webpack = require('webpack');

module.exports = {
mode: 'development',
Copy link
Contributor Author

@tkrugg tkrugg Feb 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a workaround for this issue: angular/angular-cli#8616.
This is turning off some optimisation and getting rid of the TypeError: StaticInjectorError[InjectionToken DocumentToken]: StaticInjectorError[InjectionToken DocumentToken]: error.

Note that it only affects the optimisation of the code that runs server side. The code that is shipped to the browser is optimized.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to add this explanation in the code itself, so that next time we come across this line we know why it's here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes will do!

Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works on my machine

tkrugg and others added 2 commits February 22, 2019 13:54
* chore(tests): add tests for ssr

* separate build steps for readability

* remove caret ^ from devDeps

* fix restore externals in webpack.config
@tkrugg tkrugg merged commit 7568629 into develop Feb 22, 2019
@tkrugg tkrugg deleted the ssr7 branch April 17, 2019 15:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SSR Question / Error: Angular 7 + docs example results in AlgoliaSearchUnknownError
5 participants