From 42f05143f4db8c7475c5b0b89716746099f67545 Mon Sep 17 00:00:00 2001 From: EddyVerbruggen Date: Mon, 26 Aug 2019 11:13:09 +0200 Subject: [PATCH] Nativescript Zip error on tns run ios and android #34 (bump demo-ng to N6) --- demo-ng/nsconfig.json | 3 +-- demo-ng/package.json | 43 +++++++++++++++++----------------- demo-ng/webpack.config.js | 49 ++++++++++++++------------------------- 3 files changed, 40 insertions(+), 55 deletions(-) diff --git a/demo-ng/nsconfig.json b/demo-ng/nsconfig.json index 17f1fb7..b38346b 100644 --- a/demo-ng/nsconfig.json +++ b/demo-ng/nsconfig.json @@ -1,5 +1,4 @@ { "appResourcesPath": "App_Resources", - "appPath": "src", - "useLegacyWorkflow": false + "appPath": "src" } \ No newline at end of file diff --git a/demo-ng/package.json b/demo-ng/package.json index a267819..3784310 100644 --- a/demo-ng/package.json +++ b/demo-ng/package.json @@ -2,10 +2,10 @@ "nativescript": { "id": "org.nativescript.demong.AppSync", "tns-android": { - "version": "5.4.0" + "version": "6.0.0" }, "tns-ios": { - "version": "5.4.2" + "version": "6.0.1" } }, "description": "NativeScript Application", @@ -33,28 +33,27 @@ "ci.tslint": "npm i && tslint --config '../tslint.json' 'demoapp/**/*.ts' --exclude '**/node_modules/**' --exclude '**/typings/**'" }, "dependencies": { - "@angular/animations": "~7.2.0", - "@angular/common": "~7.2.0", - "@angular/compiler": "~7.2.0", - "@angular/core": "~7.2.0", - "@angular/forms": "~7.2.0", - "@angular/http": "~7.2.0", - "@angular/platform-browser": "~7.2.0", - "@angular/platform-browser-dynamic": "~7.2.0", - "@angular/router": "~7.2.0", - "nativescript-angular": "~7.2.0", + "@angular/animations": "~8.2.3", + "@angular/common": "~8.2.3", + "@angular/compiler": "~8.2.3", + "@angular/core": "~8.2.3", + "@angular/forms": "~8.2.3", + "@angular/http": "~8.0.0-beta.10", + "@angular/platform-browser": "~8.2.3", + "@angular/platform-browser-dynamic": "~8.2.3", + "@angular/router": "~8.2.3", + "nativescript-angular": "~8.2.0", "nativescript-app-sync": "file:../publish/package/nativescript-app-sync-1.0.4.tgz", - "nativescript-theme-core": "~1.0.4", - "reflect-metadata": "~0.1.12", - "rxjs": "~6.3.0", - "tns-core-modules": "~5.4.2", - "zone.js": "~0.8.26" + "nativescript-theme-core": "~1.0.6", + "reflect-metadata": "~0.1.13", + "rxjs": "~6.5.2", + "tns-core-modules": "~6.0.7", + "zone.js": "~0.10.0" }, "devDependencies": { - "@angular/compiler-cli": "~7.2.0", - "@nativescript/schematics": "~0.5.0", - "@ngtools/webpack": "~7.2.0", - "nativescript-dev-typescript": "~0.9.0", - "nativescript-dev-webpack": "~0.24.1" + "@angular/compiler-cli": "~8.2.3", + "@ngtools/webpack": "~8.2.2", + "nativescript-dev-webpack": "~1.1.1", + "typescript": "3.4.5" } } diff --git a/demo-ng/webpack.config.js b/demo-ng/webpack.config.js index a57f5cf..d7cd1e7 100644 --- a/demo-ng/webpack.config.js +++ b/demo-ng/webpack.config.js @@ -32,7 +32,6 @@ module.exports = env => { // Default destination inside platforms//... const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot)); - const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS"; const { // The 'appPath' and 'appResourcesPath' values are fetched from @@ -43,13 +42,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; @@ -60,8 +61,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 = []; @@ -100,8 +102,15 @@ 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")}`); + } + + nsWebpack.processAppComponents(appComponents, platform); const config = { - mode: uglify ? "production" : "development", + mode: production ? "production" : "development", context: appFullPath, externals, watchOptions: { @@ -204,6 +213,7 @@ module.exports = env => { unitTesting, appFullPath, projectRoot, + ignoredFiles: nsWebpack.getUserDefinedEntries(entries, platform) } }, ].filter(loader => !!loader) @@ -253,27 +263,17 @@ module.exports = env => { // Define useful constants like TNS_WEBPACK new webpack.DefinePlugin({ "global.TNS_WEBPACK": "true", - "process": undefined, + "process": "global.process", }), // 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: "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(), @@ -283,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({