Skip to content

Commit

Permalink
Merge pull request #2 from alosaur/angular11
Browse files Browse the repository at this point in the history
Update Angular and Deno version
  • Loading branch information
irustm authored Dec 25, 2020
2 parents eff3f62 + 040a10f commit 3a9329e
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 27 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Angular renderer in Deno

Now Supported Angular 11 and Deno 1.6

This is experimental Angular SSR in Deno, and will be used as a renderer for [Alosaur](https://github.com/alosaur/alosaur) web framework, as well as handlebars, ejs, mustache.

## How to use
Expand All @@ -12,7 +14,7 @@ importmap.json:
```json
{
"imports": {
"@angular/core": "https://jspm.dev/@angular/core@10.0.1",
"@angular/core": "https://jspm.dev/@angular/core@11",
"@angular/deno": "https://deno.land/x/angular_deno/mod.ts",
"@angular/deno/": "https://deno.land/x/angular_deno/",
"zone.js": "https://jspm.dev/zone.js/dist/zone"
Expand Down
8 changes: 4 additions & 4 deletions bootstrap.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createPlatformFactory, Injector, COMPILER_OPTIONS, InjectionToken } from 'https://jspm.dev/@angular/core@10.0.1';
import { ɵplatformCoreDynamic } from 'https://jspm.dev/@angular/platform-browser-dynamic@10.0.1';
import { ResourceLoader } from 'https://jspm.dev/@angular/compiler@10.0.1';
import { createPlatformFactory, Injector, COMPILER_OPTIONS, InjectionToken } from 'https://jspm.dev/@angular/core@11';
import { ɵplatformCoreDynamic } from 'https://jspm.dev/@angular/platform-browser-dynamic@11';
import { ResourceLoader } from 'https://jspm.dev/@angular/compiler@11';
import { INITIAL_CONFIG, ɵINTERNAL_SERVER_PLATFORM_PROVIDERS as INTERNAL_SERVER_PLATFORM_PROVIDERS } from './platform-server.mjs';
import { DenoFileSystemResourceLoader } from './resource-loader.ts';

Expand Down Expand Up @@ -38,4 +38,4 @@ export async function bootstrap(module: any, document: string, resourcePath: str
}]).bootstrapModule(module, { ngZone: 'noop' }).then((ref: any) => {
return Promise.resolve(ref)
}));
}
}
10 changes: 7 additions & 3 deletions engine.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@

import { NgModuleFactory, CompilerFactory, StaticProvider, Compiler } from 'https://jspm.dev/@angular/core@10.0.1';
import { NgModuleFactory, CompilerFactory, Compiler } from 'https://jspm.dev/@angular/core@11';
import { INITIAL_CONFIG, renderModuleFactory } from './platform-server.mjs';
const { readFile } = Deno;
const decoder = new TextDecoder();

export class CommonEngine {

/** Return an instance of the platformServer compiler */

// @ts-ignore
getCompiler(): Compiler {
// @ts-ignore
const compilerFactory: CompilerFactory = this.compilerFactory;//platformCoreDynamic().injector.get(CompilerFactory);

return compilerFactory.createCompiler();
Expand All @@ -16,8 +19,9 @@ export class CommonEngine {
private factoryCacheMap = new Map<any, any>();
private readonly templateCache: Map<string, string> = new Map<string, string>()

// @ts-ignore
constructor(private compilerFactory: CompilerFactory, private moduleOrFactory?: any,
private providers: StaticProvider[] = []) { }
private providers: any[] = []) { }

/**
* Render an HTML document for a specific URL with specified
Expand Down Expand Up @@ -79,4 +83,4 @@ export class CommonEngine {
return template;
});
}
}
}
4 changes: 2 additions & 2 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Output:
</head>

<body>
<my-app _nghost-sc1="" ng-version="10.0.1">Angular in Deno v1.1.2</my-app>
<my-app _nghost-sc1="" ng-version="11.0.5">Angular in Deno v1.6.2</my-app>
</body>
</html>
```
```
4 changes: 2 additions & 2 deletions example/importmap.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"imports": {
"@angular/core": "https://jspm.dev/@angular/core@10.0.1",
"@angular/core": "https://jspm.dev/@angular/core@11",
"zone.js": "https://jspm.dev/zone.js/dist/zone"
}
}
}
2 changes: 1 addition & 1 deletion example/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { serve } from "https://deno.land/std@0.59.0/http/server.ts";
import { serve } from "https://deno.land/std@0.82.0/http/server.ts";

import { CompilerFactory, enableProdMode } from "@angular/core";
import { bootstrap, CommonEngine } from "../mod.ts";
Expand Down
20 changes: 10 additions & 10 deletions platform-server.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import _core from 'https://jspm.dev/npm:@angular/core@10.0.1!cjs';
import _core from 'https://jspm.dev/npm:@angular/core@11!cjs';
import 'https://jspm.dev/npm:rxjs@6!cjs';
import 'https://jspm.dev/npm:rxjs@6/operators!cjs';
import _common from 'https://jspm.dev/npm:@angular/common@10.0.1!cjs';
import _platformBrowser from 'https://jspm.dev/npm:@angular/platform-browser@10.0.1!cjs';
import _browser from 'https://jspm.dev/npm:@angular/animations@10.0.1/browser!cjs';
import _http from 'https://jspm.dev/npm:@angular/common@10.0.1/http!cjs';
import _compiler from 'https://jspm.dev/npm:@angular/compiler@10.0.1!cjs';
import _platformBrowserDynamic from 'https://jspm.dev/npm:@angular/platform-browser-dynamic@10.0.1!cjs';
import 'https://jspm.dev/npm:@angular/animations@10.0.1!cjs';
import _animations from 'https://jspm.dev/npm:@angular/platform-browser@10.0.1/animations!cjs';
import _common from 'https://jspm.dev/npm:@angular/common@11!cjs';
import _platformBrowser from 'https://jspm.dev/npm:@angular/platform-browser@11!cjs';
import _browser from 'https://jspm.dev/npm:@angular/animations@11/browser!cjs';
import _http from 'https://jspm.dev/npm:@angular/common@11/http!cjs';
import _compiler from 'https://jspm.dev/npm:@angular/compiler@11!cjs';
import _platformBrowserDynamic from 'https://jspm.dev/npm:@angular/platform-browser-dynamic@11!cjs';
import 'https://jspm.dev/npm:@angular/animations@11!cjs';
import _animations from 'https://jspm.dev/npm:@angular/platform-browser@11/animations!cjs';
import _rxjs from 'https://jspm.dev/npm:rxjs!cjs';
import _url from 'https://jspm.dev/npm:@jspm/core@2/nodelibs/url';
import _operators from 'https://jspm.dev/npm:rxjs/operators!cjs';
Expand Down Expand Up @@ -1858,4 +1858,4 @@ const BEFORE_APP_SERIALIZED = exports.BEFORE_APP_SERIALIZED,
export default exports;
export { BEFORE_APP_SERIALIZED, INITIAL_CONFIG, PlatformState, ServerModule, ServerTransferStateModule, VERSION, __esModule, platformDynamicServer, platformServer, renderModule, renderModuleFactory, ɵINTERNAL_SERVER_PLATFORM_PROVIDERS, ɵSERVER_RENDER_PROVIDERS, ɵServerRendererFactory2, ɵangular_packages_platform_server_platform_server_a, ɵangular_packages_platform_server_platform_server_b, ɵangular_packages_platform_server_platform_server_c, ɵangular_packages_platform_server_platform_server_d, ɵangular_packages_platform_server_platform_server_e, ɵangular_packages_platform_server_platform_server_f, ɵangular_packages_platform_server_platform_server_g };

//# sourceMappingURL=platform-server@10.0.1!cjs.map
//# sourceMappingURL=platform-server@11!cjs.map
9 changes: 5 additions & 4 deletions resource-loader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ResourceLoader } from 'https://jspm.dev/@angular/compiler@10.0.1';
import { Injector } from 'https://jspm.dev/@angular/core@10.0.1';
import { join } from "https://deno.land/std@0.65.0/path/posix.ts";
import { ResourceLoader } from 'https://jspm.dev/@angular/compiler@11';
import { Injector } from 'https://jspm.dev/@angular/core@11';
import { join } from "https://deno.land/std@0.82.0/path/posix.ts";
import { RESOURCE_PATH } from './bootstrap.ts';

const { readFile } = Deno;
Expand All @@ -10,6 +10,7 @@ export class DenoFileSystemResourceLoader extends ResourceLoader {
private readonly filesCache: Map<string, string> = new Map<string, string>()
private readonly resourcePath: string;

// @ts-ignore
constructor(private readonly injector: Injector) {
super();

Expand Down Expand Up @@ -41,4 +42,4 @@ export class DenoFileSystemResourceLoader extends ResourceLoader {
return template;
});
}
}
}

0 comments on commit 3a9329e

Please sign in to comment.