Skip to content

Commit

Permalink
update to NativeScript 6 (+ AndroidX)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickIliev committed Jun 24, 2019
1 parent fc9b85a commit 31bca25
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 39 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
14 changes: 8 additions & 6 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": "6.0.0-2019-06-10-154118-03"
},
"tns-android": {
"version": "5.4.0"
"version": "6.0.0-2019-06-11-172137-01"
}
},
"dependencies": {
Expand All @@ -26,10 +29,10 @@
"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": "7.0.0-androidx-110619",
"reflect-metadata": "~0.1.13",
"rxjs": "^6.5.2",
"tns-core-modules": "~5.4.2",
"tns-core-modules": "6.0.0-next-2019-06-20-155941-01",
"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": "0.25.0-next-2019-06-21-150426-03",
"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
44 changes: 15 additions & 29 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,15 @@ 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 +283,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 31bca25

Please sign in to comment.