Skip to content

Commit d8e495a

Browse files
authored
fix-next: stop preferring android-specific files over ios-specif… (#236)
In the current prerelease version, `*.android.ts` files are preferred over `*.ios.ts` files even when building for iOS. To reproduce execute: ``` npm i @nativescript/[email protected] ng new --shared --collection=@nativescript/schematics shared-project cd shared-project/src/app echo "console.log('ANDROID');" > print.android.ts echo "console.log('IOS');" > print.ios.ts echo "import '@src/app/print';" >> app.module.ts tns run ios ``` As a result you will see `ANDROID` printed on the console, meaning that the Android-specific file was imported even though we built the application for iOS. This behaviour is caused by the configuration of the `"paths"` property in `tsconfig.tns.json`, which tells the TS compiler to look for `*.android.ts` files first: ``` "compilerOptions": { "baseUrl": ".", "paths": { "@src/*": [ "src/*.android.ts", "src/*.ios.ts", "src/*.tns.ts", "src/*.ts" ] } } ``` This PR removes the `*.android.ts` and `*.ios.ts` lines from the configuration, delegating the `android` and `ios` file resolution to webpack.
1 parent 043bd38 commit d8e495a

File tree

3 files changed

+2
-8
lines changed

3 files changed

+2
-8
lines changed

src/add-ns/_ns-files/tsconfig__nsext__.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
"moduleResolution": "node",
66
"paths": {
77
"@src/*": [
8-
"<%= sourceDir %>/*.android.ts",
9-
"<%= sourceDir %>/*.ios.ts",
108
"<%= sourceDir %>/*.tns.ts",
119
"<%= sourceDir %>/*.ts"
1210
]
@@ -15,4 +13,4 @@
1513
"files": [
1614
"<%= sourceDir %>/main<%= nsext %>.ts"
1715
]
18-
}
16+
}

src/add-ns/index_spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ describe('Add {N} schematic', () => {
144144
expect(paths['@src/*']).toBeDefined();
145145

146146
const maps = paths['@src/*'];
147-
expect(maps).toContain('src/*.ios.ts');
148-
expect(maps).toContain('src/*.android.ts');
149147
expect(maps).toContain('src/*.tns.ts');
150148
expect(maps).toContain('src/*.ts');
151149
});

src/ng-new/shared/_files/tsconfig.tns.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
"moduleResolution": "node",
66
"paths": {
77
"@src/*": [
8-
"<%= sourcedir %>/*.android.ts",
9-
"<%= sourcedir %>/*.ios.ts",
108
"<%= sourcedir %>/*.tns.ts",
119
"<%= sourcedir %>/*.ts"
1210
]
@@ -15,4 +13,4 @@
1513
"files": [
1614
"<%= sourcedir %>/main.tns.ts"
1715
]
18-
}
16+
}

0 commit comments

Comments
 (0)