Skip to content

Commit

Permalink
Merge pull request #18 from NickIliev/nativescript6
Browse files Browse the repository at this point in the history
update to NativeScript 6 (+ AndroidX)
  • Loading branch information
NickIliev authored Jun 24, 2019
2 parents fc9b85a + 31c6de0 commit ce9d3d0
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 41 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ lib/
node_modules/*
platforms/*
hooks/*
.migration_backup

# Transpiled source files
/app/**/*.js
/app/**/*.map

# Keystores
/keystore/
# Keystores and Build files
*.apk
*.aab
*.ipa
/keystore/
*.jks
native-nick-release-key.jks
my-release-key.jks
Expand Down
3 changes: 2 additions & 1 deletion app/App_Resources/Android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
android:allowBackup="true"
android:icon="@drawable/opportuity"
android:label="@string/app_name"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">

<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
<activity
Expand Down
1 change: 0 additions & 1 deletion app/pages/rovers/rovers.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export class RoversComponent implements OnInit, AfterViewInit {
}

this._tempArr = itemsList;

this.roverPhotos = RxObservable.create(subscriber => {
this._subscr = subscriber;
subscriber.next(this._tempArr);
Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.curiosity",
"tns-ios": {
"version": "next"
},
"tns-android": {
"version": "5.4.0"
"version": "next"
}
},
"dependencies": {
Expand All @@ -19,17 +22,17 @@
"@angular/platform-browser": "8.0.0",
"@angular/platform-browser-dynamic": "8.0.0",
"@angular/router": "8.0.0",
"nativescript-angular": "~8.0.1",
"nativescript-angular": "next",
"nativescript-app-center": "^1.0.3",
"nativescript-cardview": "^3.2.0",
"nativescript-permissions": "^1.3.6",
"nativescript-plugin-firebase": "^9.0.1",
"nativescript-social-share": "^1.5.2",
"nativescript-theme-core": "^1.0.6",
"nativescript-ui-sidedrawer": "^6.0.0",
"nativescript-ui-sidedrawer": "androidx",
"reflect-metadata": "~0.1.13",
"rxjs": "^6.5.2",
"tns-core-modules": "~5.4.2",
"tns-core-modules": "next",
"zone.js": "^0.9.1"
},
"devDependencies": {
Expand All @@ -42,11 +45,10 @@
"mocha": "~5.2.0",
"mochawesome": "~3.1.2",
"nativescript-dev-appium": "next",
"nativescript-dev-typescript": "~0.10.0",
"nativescript-dev-webpack": "~0.24.1",
"nativescript-dev-webpack": "next",
"tns-platform-declarations": "~5.4.2",
"tslint": "^5.11.0",
"typescript": "~3.4.5"
"typescript": "3.4.1"
},
"scripts": {
"tslint": "tslint -p tsconfig.json",
Expand Down
45 changes: 15 additions & 30 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ module.exports = env => {

// You can provide the following flags when running 'tns run android|ios'
aot, // --env.aot
snapshot, // --env.snapshot
snapshot, // --env.snapshot,
production, // --env.production
uglify, // --env.uglify
report, // --env.report
sourceMap, // --env.sourceMap
hiddenSourceMap, // --env.hiddenSourceMap
hmr, // --env.hmr,
unitTesting, // --env.unitTesting
verbose, // --env.verbose
} = env;

const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
Expand All @@ -60,8 +62,9 @@ module.exports = env => {
const entryModule = `${nsWebpack.getEntryModule(appFullPath, platform)}.ts`;
const entryPath = `.${sep}${entryModule}`;
const entries = { bundle: entryPath };
if (platform === "ios") {
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js";
const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some(e => e.indexOf("tns-core-modules") > -1);
if (platform === "ios" && !areCoreModulesExternal) {
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules";
};

const ngCompilerTransformers = [];
Expand Down Expand Up @@ -100,8 +103,14 @@ module.exports = env => {

let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);

const itemsToClean = [`${dist}/**/*`];
if (platform === "android") {
itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "src", "main", "assets", "snapshots")}`);
itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}`);
}

const config = {
mode: uglify ? "production" : "development",
mode: production ? "production" : "development",
context: appFullPath,
externals,
watchOptions: {
Expand Down Expand Up @@ -256,25 +265,14 @@ module.exports = env => {
"process": undefined,
}),
// Remove all files from the out dir.
new CleanWebpackPlugin([`${dist}/**/*`]),
new CleanWebpackPlugin(itemsToClean, { verbose: !!verbose }),
// Copy assets to out dir. Add your own globs as needed.
new CopyWebpackPlugin([
{ from: { glob: "settings.json"} }, // HERE
{ from: { glob: "fonts/**" } },
{ from: { glob: "**/*.jpg" } },
{ from: { glob: "**/*.png" } },
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
// Generate a bundle starter script and activate it in package.json
new nsWebpack.GenerateBundleStarterPlugin(
// Don't include `runtime.js` when creating a snapshot. The plugin
// configures the WebPack runtime to be generated inside the snapshot
// module and no `runtime.js` module exist.
(snapshot ? [] : ["./runtime"])
.concat([
"./vendor",
"./bundle",
])
),
new nsWebpack.GenerateNativeScriptEntryPointsPlugin("bundle"),
// For instructions on how to set up workers with webpack
// check out https://github.com/nativescript/worker-loader
new NativeScriptWorkerPlugin(),
Expand All @@ -284,19 +282,6 @@ module.exports = env => {
],
};

// Copy the native app resources to the out dir
// only if doing a full build (tns run/build) and not previewing (tns preview)
if (!externals || externals.length === 0) {
config.plugins.push(new CopyWebpackPlugin([
{
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
context: projectRoot
},
]));
}


if (report) {
// Generate report files for bundles content
config.plugins.push(new BundleAnalyzerPlugin({
Expand Down

0 comments on commit ce9d3d0

Please sign in to comment.