Permalink
Browse files

feat: enable AOT compilation (#86)

  • Loading branch information...
1 parent 04d5d11 commit cdc9f64e1ee19fe5d1e2c9f5d778a05d92dd08bf @mlaval mlaval committed on GitHub Sep 12, 2016
Showing with 1,436 additions and 417 deletions.
  1. +3 −1 .gitignore
  2. +19 −3 doc/pages/bootstrap.jade
  3. +6 −2 doc/pages/router.jade
  4. +17 −0 factory.tsconfig.json
  5. +23 −0 fake-react-native.d.ts
  6. +223 −90 gulpfile.js
  7. +6 −2 package.json
  8. +4 −0 sample/index.android.aot.js
  9. +2 −2 sample/index.android.ts
  10. +4 −0 sample/index.ios.aot.js
  11. +2 −2 sample/index.ios.ts
  12. 0 sample/samples/{common → android}/animation.ts
  13. 0 sample/samples/{common → android}/gestures.ts
  14. +3 −6 sample/samples/{common → android}/http.ts
  15. +1 −1 sample/samples/android/kitchensink.ts
  16. +14 −11 sample/samples/android/module.ts
  17. +7 −17 sample/samples/{common → android}/todomvc.ts
  18. +4 −8 sample/samples/{common → android}/webview.ts
  19. +147 −0 sample/samples/ios/animation.ts
  20. +89 −0 sample/samples/ios/gestures.ts
  21. +35 −0 sample/samples/ios/http.ts
  22. +1 −1 sample/samples/ios/kitchensink.ts
  23. +14 −11 sample/samples/ios/module.ts
  24. +329 −0 sample/samples/ios/todomvc.ts
  25. +50 −0 sample/samples/ios/webview.ts
  26. +28 −0 sample/tsconfig.json
  27. +1 −0 src/aot.ts
  28. +5 −5 src/components/android/drawer_layout.ts
  29. +3 −3 src/components/android/pager_layout.ts
  30. +5 −5 src/components/android/progress_bar.ts
  31. +11 −11 src/components/android/toolbar.ts
  32. +5 −5 src/components/common/activity_indicator.ts
  33. +18 −18 src/components/common/component.ts
  34. +9 −9 src/components/common/image.ts
  35. +6 −6 src/components/common/picker.ts
  36. +8 −8 src/components/common/refresh_control.ts
  37. +33 −38 src/components/common/scrollview.ts
  38. +11 −11 src/components/common/slider.ts
  39. +5 −5 src/components/common/switch.ts
  40. +5 −5 src/components/common/text.ts
  41. +24 −24 src/components/common/textinput.ts
  42. +11 −11 src/components/common/webview.ts
  43. +6 −6 src/components/ios/date_picker.ts
  44. +17 −17 src/components/ios/map_view.ts
  45. +22 −22 src/components/ios/navigator.ts
  46. +6 −6 src/components/ios/progress_view.ts
  47. +5 −5 src/components/ios/segmented_control.ts
  48. +4 −4 src/components/ios/tabbar.ts
  49. +6 −6 src/components/ios/tabbar_item.ts
  50. +3 −0 src/events/hammer.ts
  51. +6 −2 src/http/http_module.ts
  52. +1 −2 src/index.ts
  53. +1 −0 src/jit.ts
  54. +62 −0 src/renderer/bootstrap_aot.ts
  55. +4 −2 src/renderer/{bootstrap.ts → bootstrap_jit.ts}
  56. +7 −23 src/router/router_module.ts
  57. +63 −0 src/router/router_outlet.ts
  58. +29 −0 src/tsconfig.json
  59. +2 −0 src/wrapper/wrapper_impl.ts
  60. +1 −1 typings.json
View
@@ -3,4 +3,6 @@ dist
typings
*.log
.idea
-.DS_Store
+.DS_Store
+*.ngfactory.ts
+es6
@@ -6,15 +6,31 @@ block content
:marked
# bootstrap
- To bootstrap an application, you must use the special method `bootstrapReactNative`.
+
+ ## JIT compilation
+
+ To bootstrap an application with JIT compilation, you must use the special methods `bootstrapReactNativeJIT`.
```
- import {bootstrapReactNative} from 'angular2-react-native';
+ import {bootstrapReactNativeJIT} from 'angular2-react-native/jit';
import {MyAppModule} from "./app/module";
- bootstrapReactNative('myApp', MyAppModule);
+ bootstrapReactNativeJIT('myApp', MyAppModule);
```
+ ## AOT compilation
+
+ To bootstrap an application with AOT compilation, you must use the special methods `bootstrapReactNativeAOT`.
+
+ ```
+ import {bootstrapReactNativeAOT} from 'angular2-react-native/aot';
+ import {MyAppModuleNgFactory} from "./app/module.ngfactory";
+
+ bootstrapReactNativeAOT('myApp', MyAppModule);
+ ```
+
+ ## Main module
+
The main module must import `ReactNativeAndroidModule` or `ReactNativeiOSModule` depending on the platform targetted:
```
@NgModule({
@@ -8,7 +8,8 @@ block content
# Router
The rooter module of Angular 2 can be used as is in applications.
- 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.
+ The only thing to be done is to import `ReactNativeRouterModule` in the main module of the application (see below),
+ and use the static `RouterModule.forRoot` method to configure routes.
It uses a mock of `LocationStrategy`. Manipulating the location triggers a navigation of the router.
@@ -19,9 +20,12 @@ block content
{ path: 'b', component: CompB }
];
+ export const providers: Provider[] = RouterModule.forRoot(appRoutes)['providers'];
+
@NgModule({
declarations: [Example, CompA, CompB, ...],
- imports: [ReactNativeAndroidModule, CommonModule, ReactNativeRouterModule.forRoot(appRoutes)],
+ imports: [ReactNativeAndroidModule, CommonModule, ReactNativeRouterModule],
+ providers: [providers, {provide: LocationStrategy, useClass: ReactNativeLocationStrategy}],
bootstrap: [Example]
})
export class MyAppModule {}
View
@@ -0,0 +1,17 @@
+{
+ "compilerOptions": {
+ "baseUrl": ".",
+ "declaration": true,
+ "stripInternal": true,
+ "experimentalDecorators": true,
+ "module": "es2015",
+ "moduleResolution": "node",
+ "outDir": "../factories_out",
+ "rootDir": ".",
+ "sourceMap": true,
+ "inlineSources": true,
+ "target": "es5",
+ "skipLibCheck": true,
+ "lib": [ "es2015", "dom" ]
+ }
+}
@@ -0,0 +1,23 @@
+//TODO: switch to react-native.d.ts form typings
+
+declare module "react-native" {
+ export var StyleSheet: any;
+ export var Alert: any;
+ export var Linking: any;
+ export var Clipboard: any
+ export var Platform: any;
+ export var PixelRatio: any;
+ export var NetInfo: any;
+ export var AppState: any;
+ export var NativeModules: any;
+ export var processColor: any;
+ export var AsyncStorage: any;
+
+ export var DatePickerAndroid: any;
+ export var TimePickerAndroid: any;
+ export var BackAndroid: any;
+ export var ToastAndroid: any;
+
+ export var ActionSheetIOS: any;
+ export var AlertIOS: any;
+}
Oops, something went wrong.

0 comments on commit cdc9f64

Please sign in to comment.