chore(angular-server): init angular-server package (#18950)

This commit is contained in:
Adam Bradley 2019-07-30 09:50:23 -05:00 committed by GitHub
parent f08ac68e0b
commit e3a5d1f93a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 167 additions and 0 deletions

6
lerna.json Normal file
View File

@ -0,0 +1,6 @@
{
"packages": [
"packages/*"
],
"version": "0.0.0"
}

View File

@ -1,5 +1,6 @@
{
"private": true,
"description": "Ionic mono-repo root package.json, used mainly to execute build scripts. This package is not published to npm.",
"scripts": {
"build": "node .scripts/build.js",
"release.dev": "node .scripts/release-dev.js",
@ -13,7 +14,9 @@
"execa": "^0.10.0",
"fs-extra": "^7.0.0",
"inquirer": "^6.0.0",
"lerna": "^3.16.2",
"listr": "^0.14.0",
"rimraf": "^2.6.3",
"semver": "^5.5.0",
"turbocolor": "^2.4.1"
},

View File

@ -0,0 +1 @@
package-lock=false

View File

@ -0,0 +1,39 @@
{
"name": "@ionic/angular-server",
"description": "Angular SSR Module for Ionic",
"version": "0.0.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "ngc -p ./tsconfig.json",
"build.prod": "npm run clean && npm run build",
"clean": "rm -rf ./dist"
},
"peerDependencies": {
"@angular-devkit/core": "~8.0.0",
"@angular/common": "~8.0.0",
"@angular/core": "~8.0.0",
"@angular/platform-server": "~8.0.0",
"@ionic/core": "*",
"rxjs": ">=6.2.0",
"zone.js": ">=0.8.26"
},
"devDependencies": {
"@angular-devkit/core": "~8.0.0",
"@angular/animations": "~8.0.0",
"@angular/common": "~8.0.0",
"@angular/compiler": "~8.0.0",
"@angular/compiler-cli": "~8.0.0",
"@angular/core": "~8.0.0",
"@angular/platform-browser": "~8.0.0",
"@angular/platform-server": "~8.0.0",
"@angular/router": "~8.0.0",
"rxjs": "^6.4.0",
"tsickle": "^0.34.0",
"typescript": "~3.4.3",
"zone.js": "~0.9.1"
}
}

View File

@ -0,0 +1,3 @@
# @ionic/angular-server
Angular SSR Module for Ionic components.

View File

@ -0,0 +1,51 @@
import { DOCUMENT } from '@angular/common';
import { APP_ID, NgModule } from '@angular/core';
import { BEFORE_APP_SERIALIZED } from '@angular/platform-server';
import { hydrateDocument } from '@ionic/core/hydrate';
// @dynamic
@NgModule({
providers: [
{
provide: BEFORE_APP_SERIALIZED,
useFactory: hydrateIonicComponents,
multi: true,
deps: [DOCUMENT, APP_ID]
}
]
})
export class IonicServerModule {}
// @dynamic
export function hydrateIonicComponents(doc: any, appId: any) {
return () => {
return hydrateDocument(doc, {
clientHydrateAnnotations: false
})
.then(hydrateResults => {
hydrateResults.diagnostics.forEach(d => {
if (d.type === 'error') {
console.error(d.messageText);
} else if (d.type === 'debug') {
console.debug(d.messageText);
} else {
console.log(d.messageText);
}
});
if (doc.head != null) {
const styleElms = doc.head.querySelectorAll('style[data-styles]') as NodeListOf<HTMLStyleElement>;
for (let i = 0; i < styleElms.length; i++) {
styleElms[i].setAttribute('ng-transition', appId);
}
}
if (doc.body != null) {
const ionPages = doc.body.querySelectorAll('.ion-page.ion-page-invisible') as NodeListOf<HTMLElement>;
for (let i = 0; i < ionPages.length; i++) {
ionPages[i].classList.remove('ion-page-invisible');
}
}
});
};
}

View File

@ -0,0 +1,18 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist"
},
"files": [
"src/ionic-server-module.ts"
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit" : true,
"flatModuleOutFile": "./index.js",
"flatModuleId": "@ionic/angular-server",
"skipTemplateCodegen": true,
"fullTemplateTypeCheck": false
}
}

46
tsconfig.json Normal file
View File

@ -0,0 +1,46 @@
{
"compilerOptions": {
"alwaysStrict": true,
"strict": true,
"allowSyntheticDefaultImports": true,
"allowUnreachableCode": false,
"declaration": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"lib": [
"dom",
"es2017"
],
"module": "es2015",
"moduleResolution": "node",
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"pretty": true,
"removeComments": false,
"strictPropertyInitialization": false,
"target": "es2017",
"baseUrl": ".",
"paths": {
"@ionic/core/hydrate": [
"./core/hydrate"
],
"@ionic/core": [
"./core"
],
"@ionic/angular": [
"./angular"
],
"@ionic/angular-server": [
"./packages/angular-server"
],
"@ionic/react": [
"./react"
],
"@ionic/vue": [
"./vue"
]
}
}
}