Skip to content

Commit aa354c9

Browse files
committed
More pre-build hacks to run handle Angular imports
1 parent 69cb759 commit aa354c9

File tree

4 files changed

+50
-14
lines changed

4 files changed

+50
-14
lines changed

ng-sample/gruntfile.js

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var path = require("path");
22
var fs = require("fs");
3+
var shelljs = require("shelljs");
34

45
module.exports = function(grunt) {
56
grunt.loadNpmTasks('grunt-ts');
@@ -18,10 +19,19 @@ module.exports = function(grunt) {
1819
build: {
1920
src: [
2021
'src/**/*.ts',
22+
// This one refers to the Angular package structure from npm
23+
// and doesn't compile against the dev source.
24+
'!src/nativescript-angular/application.d.ts',
2125
],
2226
dest: 'app',
2327
options: {
2428
fast: "never",
29+
30+
// Resolve non-relative modules like "ui/styling/style"
31+
// based on the project root (not on node_modules which
32+
// is the typescript 1.6+ default)
33+
additionalFlags: '--moduleResolution classic',
34+
2535
module: "commonjs",
2636
target: "es5",
2737
sourceMap: true,
@@ -47,23 +57,41 @@ module.exports = function(grunt) {
4757
expand: true,
4858
cwd: '../src',
4959
src: [
60+
'css/**/*',
5061
'nativescript-angular/**/*',
5162
],
5263
dest: 'src'
5364
},
54-
tnsifyAngularAndroid: {
65+
tnsifyAngular: {
5566
expand: true,
5667
cwd: 'app/',
5768
src: [
5869
"angular2/**/*",
70+
"css/**/*",
5971
"nativescript-angular/**/*",
6072
],
73+
dest: 'node_modules',
74+
},
75+
tnsifyCssStub: {
76+
expand: true,
77+
cwd: 'app/',
78+
src: [
79+
"css/**/*",
80+
],
81+
dest: 'node_modules/tns-core-modules',
82+
},
83+
tnsifyRxJsAngular: {
84+
expand: true,
85+
cwd: 'node_modules/',
86+
src: [
87+
"@reactivex/**/*",
88+
],
6189
dest: 'platforms/android/src/main/assets/app/tns_modules',
6290
},
6391
},
6492
shell: {
6593
updateAngular: {
66-
command: "grunt copy:angularSource --angularDest ng-sample/src",
94+
command: "grunt prepareAngular --angularDest ng-sample/src",
6795
options: {
6896
execOptions: {
6997
cwd: '..',
@@ -81,6 +109,7 @@ module.exports = function(grunt) {
81109
src: [
82110
'angular2',
83111
'nativescript-angular',
112+
'css',
84113
'**/*.js.map',
85114
]
86115
},
@@ -140,8 +169,16 @@ module.exports = function(grunt) {
140169
"prepareQuerystringPackage",
141170
]);
142171

172+
grunt.registerTask("fixAngularPackageJson", function() {
173+
//remove lines containing invalid chars
174+
shelljs.sed('-i', /.*<%.*\n/g, '', 'node_modules/angular2/package.json');
175+
});
176+
143177
grunt.registerTask("preDeploy", [
144-
"copy:tnsifyAngularAndroid",
178+
"copy:tnsifyAngular",
179+
"fixAngularPackageJson",
180+
"copy:tnsifyCssStub",
181+
"copy:tnsifyRxJsAngular",
145182
"clean:appBeforeDeploy",
146183
]);
147184

ng-sample/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
},
2424
"homepage": "https://github.com/NativeScript/template-hello-world",
2525
"dependencies": {
26-
"reflect-metadata": "0.1.0",
27-
"rtts_assert": "2.0.0-alpha.26",
28-
"zone.js": "0.5.0",
29-
"rx": "2.5.3",
26+
"@reactivex/rxjs": "0.0.0-prealpha.3",
27+
"reflect-metadata": "0.1.1",
28+
"zone.js": "0.5.7",
3029
"parse5": "1.4.2",
3130
"punycode": "1.3.2",
3231
"querystring": "0.2.0",
@@ -38,7 +37,8 @@
3837
"grunt-contrib-copy": "0.8.0",
3938
"grunt-contrib-clean": "0.6.0",
4039
"grunt-shell": "1.1.2",
41-
"typescript": "1.5.3"
40+
"shelljs": "^0.5.3",
41+
"typescript": "1.6.2"
4242
},
4343
"nativescript": {
4444
"id": "org.nativescript.ngsample",

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
"scripts": {},
1616
"dependencies": {
1717
"angular2": "2.0.0-alpha.36",
18+
"@reactivex/rxjs": "0.0.0-prealpha.3",
1819
"parse5": "1.4.2",
1920
"punycode": "1.3.2",
2021
"querystring": "0.2.0",
2122
"url": "0.10.3",
22-
"reflect-metadata": "0.1.0",
23-
"rtts_assert": "2.0.0-alpha.36",
24-
"rx": "2.5.3",
25-
"zone.js": "0.5.3"
23+
"reflect-metadata": "0.1.1",
24+
"zone.js": "0.5.7"
2625
},
2726
"devDependencies": {
2827
"grunt": "0.4.5",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
declare module "nativescript-angular/application" {
22
import { Type, ApplicationRef, Binding } from 'angular2/angular2';
33

4-
export type BindingList = List<Type | Binding | List<any>>;
5-
export function nativeScriptBootstrap(appComponentType: any, componentInjectableBindings?: BindingList): Promise<ApplicationRef>;
4+
export type BindingArray = Array<Type | Binding | Array<any>>;
5+
export function nativeScriptBootstrap(appComponentType: any, componentInjectableBindings?: BindingArray): Promise<ApplicationRef>;
66
}

0 commit comments

Comments
 (0)