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

Commit cdc9f64

Browse files
authored
feat: enable AOT compilation (#86)
1 parent 04d5d11 commit cdc9f64

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1436
-417
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ dist
33
typings
44
*.log
55
.idea
6-
.DS_Store
6+
.DS_Store
7+
*.ngfactory.ts
8+
es6

doc/pages/bootstrap.jade

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,31 @@ block content
66

77
:marked
88
# bootstrap
9-
To bootstrap an application, you must use the special method `bootstrapReactNative`.
9+
10+
## JIT compilation
11+
12+
To bootstrap an application with JIT compilation, you must use the special methods `bootstrapReactNativeJIT`.
1013

1114
```
12-
import {bootstrapReactNative} from 'angular2-react-native';
15+
import {bootstrapReactNativeJIT} from 'angular2-react-native/jit';
1316
import {MyAppModule} from "./app/module";
1417

15-
bootstrapReactNative('myApp', MyAppModule);
18+
bootstrapReactNativeJIT('myApp', MyAppModule);
1619
```
1720

21+
## AOT compilation
22+
23+
To bootstrap an application with AOT compilation, you must use the special methods `bootstrapReactNativeAOT`.
24+
25+
```
26+
import {bootstrapReactNativeAOT} from 'angular2-react-native/aot';
27+
import {MyAppModuleNgFactory} from "./app/module.ngfactory";
28+
29+
bootstrapReactNativeAOT('myApp', MyAppModule);
30+
```
31+
32+
## Main module
33+
1834
The main module must import `ReactNativeAndroidModule` or `ReactNativeiOSModule` depending on the platform targetted:
1935
```
2036
@NgModule({

doc/pages/router.jade

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ block content
88
# Router
99

1010
The rooter module of Angular 2 can be used as is in applications.
11-
The only thing to be done is to import `ReactNativeRouterModule` in the main module of the application (see below), and use the static `forRoot` method to configure routes.
11+
The only thing to be done is to import `ReactNativeRouterModule` in the main module of the application (see below),
12+
and use the static `RouterModule.forRoot` method to configure routes.
1213

1314
It uses a mock of `LocationStrategy`. Manipulating the location triggers a navigation of the router.
1415

@@ -19,9 +20,12 @@ block content
1920
{ path: 'b', component: CompB }
2021
];
2122

23+
export const providers: Provider[] = RouterModule.forRoot(appRoutes)['providers'];
24+
2225
@NgModule({
2326
declarations: [Example, CompA, CompB, ...],
24-
imports: [ReactNativeAndroidModule, CommonModule, ReactNativeRouterModule.forRoot(appRoutes)],
27+
imports: [ReactNativeAndroidModule, CommonModule, ReactNativeRouterModule],
28+
providers: [providers, {provide: LocationStrategy, useClass: ReactNativeLocationStrategy}],
2529
bootstrap: [Example]
2630
})
2731
export class MyAppModule {}

factory.tsconfig.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": ".",
4+
"declaration": true,
5+
"stripInternal": true,
6+
"experimentalDecorators": true,
7+
"module": "es2015",
8+
"moduleResolution": "node",
9+
"outDir": "../factories_out",
10+
"rootDir": ".",
11+
"sourceMap": true,
12+
"inlineSources": true,
13+
"target": "es5",
14+
"skipLibCheck": true,
15+
"lib": [ "es2015", "dom" ]
16+
}
17+
}

fake-react-native.d.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//TODO: switch to react-native.d.ts form typings
2+
3+
declare module "react-native" {
4+
export var StyleSheet: any;
5+
export var Alert: any;
6+
export var Linking: any;
7+
export var Clipboard: any
8+
export var Platform: any;
9+
export var PixelRatio: any;
10+
export var NetInfo: any;
11+
export var AppState: any;
12+
export var NativeModules: any;
13+
export var processColor: any;
14+
export var AsyncStorage: any;
15+
16+
export var DatePickerAndroid: any;
17+
export var TimePickerAndroid: any;
18+
export var BackAndroid: any;
19+
export var ToastAndroid: any;
20+
21+
export var ActionSheetIOS: any;
22+
export var AlertIOS: any;
23+
}

0 commit comments

Comments
 (0)