mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-16 10:01:59 +08:00
chore(angular-server): init angular-server package (#18950)
This commit is contained in:
6
lerna.json
Normal file
6
lerna.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"packages": [
|
||||||
|
"packages/*"
|
||||||
|
],
|
||||||
|
"version": "0.0.0"
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"description": "Ionic mono-repo root package.json, used mainly to execute build scripts. This package is not published to npm.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node .scripts/build.js",
|
"build": "node .scripts/build.js",
|
||||||
"release.dev": "node .scripts/release-dev.js",
|
"release.dev": "node .scripts/release-dev.js",
|
||||||
@ -13,7 +14,9 @@
|
|||||||
"execa": "^0.10.0",
|
"execa": "^0.10.0",
|
||||||
"fs-extra": "^7.0.0",
|
"fs-extra": "^7.0.0",
|
||||||
"inquirer": "^6.0.0",
|
"inquirer": "^6.0.0",
|
||||||
|
"lerna": "^3.16.2",
|
||||||
"listr": "^0.14.0",
|
"listr": "^0.14.0",
|
||||||
|
"rimraf": "^2.6.3",
|
||||||
"semver": "^5.5.0",
|
"semver": "^5.5.0",
|
||||||
"turbocolor": "^2.4.1"
|
"turbocolor": "^2.4.1"
|
||||||
},
|
},
|
||||||
|
1
packages/angular-server/.npmrc
Normal file
1
packages/angular-server/.npmrc
Normal file
@ -0,0 +1 @@
|
|||||||
|
package-lock=false
|
39
packages/angular-server/package.json
Normal file
39
packages/angular-server/package.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
3
packages/angular-server/readme.md
Normal file
3
packages/angular-server/readme.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# @ionic/angular-server
|
||||||
|
|
||||||
|
Angular SSR Module for Ionic components.
|
51
packages/angular-server/src/ionic-server-module.ts
Normal file
51
packages/angular-server/src/ionic-server-module.ts
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
18
packages/angular-server/tsconfig.json
Normal file
18
packages/angular-server/tsconfig.json
Normal 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
46
tsconfig.json
Normal 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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user