Skip to content

Commit e3a5d1f

Browse files
authored
chore(angular-server): init angular-server package (ionic-team#18950)
1 parent f08ac68 commit e3a5d1f

File tree

8 files changed

+167
-0
lines changed

8 files changed

+167
-0
lines changed

lerna.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"packages": [
3+
"packages/*"
4+
],
5+
"version": "0.0.0"
6+
}

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"private": true,
3+
"description": "Ionic mono-repo root package.json, used mainly to execute build scripts. This package is not published to npm.",
34
"scripts": {
45
"build": "node .scripts/build.js",
56
"release.dev": "node .scripts/release-dev.js",
@@ -13,7 +14,9 @@
1314
"execa": "^0.10.0",
1415
"fs-extra": "^7.0.0",
1516
"inquirer": "^6.0.0",
17+
"lerna": "^3.16.2",
1618
"listr": "^0.14.0",
19+
"rimraf": "^2.6.3",
1720
"semver": "^5.5.0",
1821
"turbocolor": "^2.4.1"
1922
},

packages/angular-server/.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

packages/angular-server/package.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "@ionic/angular-server",
3+
"description": "Angular SSR Module for Ionic",
4+
"version": "0.0.0",
5+
"main": "dist/index.js",
6+
"types": "dist/index.d.ts",
7+
"files": [
8+
"dist"
9+
],
10+
"scripts": {
11+
"build": "ngc -p ./tsconfig.json",
12+
"build.prod": "npm run clean && npm run build",
13+
"clean": "rm -rf ./dist"
14+
},
15+
"peerDependencies": {
16+
"@angular-devkit/core": "~8.0.0",
17+
"@angular/common": "~8.0.0",
18+
"@angular/core": "~8.0.0",
19+
"@angular/platform-server": "~8.0.0",
20+
"@ionic/core": "*",
21+
"rxjs": ">=6.2.0",
22+
"zone.js": ">=0.8.26"
23+
},
24+
"devDependencies": {
25+
"@angular-devkit/core": "~8.0.0",
26+
"@angular/animations": "~8.0.0",
27+
"@angular/common": "~8.0.0",
28+
"@angular/compiler": "~8.0.0",
29+
"@angular/compiler-cli": "~8.0.0",
30+
"@angular/core": "~8.0.0",
31+
"@angular/platform-browser": "~8.0.0",
32+
"@angular/platform-server": "~8.0.0",
33+
"@angular/router": "~8.0.0",
34+
"rxjs": "^6.4.0",
35+
"tsickle": "^0.34.0",
36+
"typescript": "~3.4.3",
37+
"zone.js": "~0.9.1"
38+
}
39+
}

packages/angular-server/readme.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# @ionic/angular-server
2+
3+
Angular SSR Module for Ionic components.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { DOCUMENT } from '@angular/common';
2+
import { APP_ID, NgModule } from '@angular/core';
3+
import { BEFORE_APP_SERIALIZED } from '@angular/platform-server';
4+
import { hydrateDocument } from '@ionic/core/hydrate';
5+
6+
// @dynamic
7+
@NgModule({
8+
providers: [
9+
{
10+
provide: BEFORE_APP_SERIALIZED,
11+
useFactory: hydrateIonicComponents,
12+
multi: true,
13+
deps: [DOCUMENT, APP_ID]
14+
}
15+
]
16+
})
17+
export class IonicServerModule {}
18+
19+
// @dynamic
20+
export function hydrateIonicComponents(doc: any, appId: any) {
21+
return () => {
22+
return hydrateDocument(doc, {
23+
clientHydrateAnnotations: false
24+
})
25+
.then(hydrateResults => {
26+
hydrateResults.diagnostics.forEach(d => {
27+
if (d.type === 'error') {
28+
console.error(d.messageText);
29+
} else if (d.type === 'debug') {
30+
console.debug(d.messageText);
31+
} else {
32+
console.log(d.messageText);
33+
}
34+
});
35+
36+
if (doc.head != null) {
37+
const styleElms = doc.head.querySelectorAll('style[data-styles]') as NodeListOf<HTMLStyleElement>;
38+
for (let i = 0; i < styleElms.length; i++) {
39+
styleElms[i].setAttribute('ng-transition', appId);
40+
}
41+
}
42+
43+
if (doc.body != null) {
44+
const ionPages = doc.body.querySelectorAll('.ion-page.ion-page-invisible') as NodeListOf<HTMLElement>;
45+
for (let i = 0; i < ionPages.length; i++) {
46+
ionPages[i].classList.remove('ion-page-invisible');
47+
}
48+
}
49+
});
50+
};
51+
}

packages/angular-server/tsconfig.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": "../../tsconfig",
3+
"compilerOptions": {
4+
"rootDir": "src",
5+
"outDir": "dist"
6+
},
7+
"files": [
8+
"src/ionic-server-module.ts"
9+
],
10+
"angularCompilerOptions": {
11+
"annotateForClosureCompiler": true,
12+
"strictMetadataEmit" : true,
13+
"flatModuleOutFile": "./index.js",
14+
"flatModuleId": "@ionic/angular-server",
15+
"skipTemplateCodegen": true,
16+
"fullTemplateTypeCheck": false
17+
}
18+
}

tsconfig.json

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"compilerOptions": {
3+
"alwaysStrict": true,
4+
"strict": true,
5+
"allowSyntheticDefaultImports": true,
6+
"allowUnreachableCode": false,
7+
"declaration": true,
8+
"experimentalDecorators": true,
9+
"forceConsistentCasingInFileNames": true,
10+
"lib": [
11+
"dom",
12+
"es2017"
13+
],
14+
"module": "es2015",
15+
"moduleResolution": "node",
16+
"noImplicitAny": true,
17+
"noImplicitReturns": true,
18+
"noUnusedLocals": true,
19+
"noUnusedParameters": true,
20+
"pretty": true,
21+
"removeComments": false,
22+
"strictPropertyInitialization": false,
23+
"target": "es2017",
24+
"baseUrl": ".",
25+
"paths": {
26+
"@ionic/core/hydrate": [
27+
"./core/hydrate"
28+
],
29+
"@ionic/core": [
30+
"./core"
31+
],
32+
"@ionic/angular": [
33+
"./angular"
34+
],
35+
"@ionic/angular-server": [
36+
"./packages/angular-server"
37+
],
38+
"@ionic/react": [
39+
"./react"
40+
],
41+
"@ionic/vue": [
42+
"./vue"
43+
]
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)