Skip to content

Commit 42f0514

Browse files
Nativescript Zip error on tns run ios and android #34 (bump demo-ng to N6)
1 parent 71bc9e9 commit 42f0514

File tree

3 files changed

+40
-55
lines changed

3 files changed

+40
-55
lines changed

demo-ng/nsconfig.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
22
"appResourcesPath": "App_Resources",
3-
"appPath": "src",
4-
"useLegacyWorkflow": false
3+
"appPath": "src"
54
}

demo-ng/package.json

+21-22
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"nativescript": {
33
"id": "org.nativescript.demong.AppSync",
44
"tns-android": {
5-
"version": "5.4.0"
5+
"version": "6.0.0"
66
},
77
"tns-ios": {
8-
"version": "5.4.2"
8+
"version": "6.0.1"
99
}
1010
},
1111
"description": "NativeScript Application",
@@ -33,28 +33,27 @@
3333
"ci.tslint": "npm i && tslint --config '../tslint.json' 'demoapp/**/*.ts' --exclude '**/node_modules/**' --exclude '**/typings/**'"
3434
},
3535
"dependencies": {
36-
"@angular/animations": "~7.2.0",
37-
"@angular/common": "~7.2.0",
38-
"@angular/compiler": "~7.2.0",
39-
"@angular/core": "~7.2.0",
40-
"@angular/forms": "~7.2.0",
41-
"@angular/http": "~7.2.0",
42-
"@angular/platform-browser": "~7.2.0",
43-
"@angular/platform-browser-dynamic": "~7.2.0",
44-
"@angular/router": "~7.2.0",
45-
"nativescript-angular": "~7.2.0",
36+
"@angular/animations": "~8.2.3",
37+
"@angular/common": "~8.2.3",
38+
"@angular/compiler": "~8.2.3",
39+
"@angular/core": "~8.2.3",
40+
"@angular/forms": "~8.2.3",
41+
"@angular/http": "~8.0.0-beta.10",
42+
"@angular/platform-browser": "~8.2.3",
43+
"@angular/platform-browser-dynamic": "~8.2.3",
44+
"@angular/router": "~8.2.3",
45+
"nativescript-angular": "~8.2.0",
4646
"nativescript-app-sync": "file:../publish/package/nativescript-app-sync-1.0.4.tgz",
47-
"nativescript-theme-core": "~1.0.4",
48-
"reflect-metadata": "~0.1.12",
49-
"rxjs": "~6.3.0",
50-
"tns-core-modules": "~5.4.2",
51-
"zone.js": "~0.8.26"
47+
"nativescript-theme-core": "~1.0.6",
48+
"reflect-metadata": "~0.1.13",
49+
"rxjs": "~6.5.2",
50+
"tns-core-modules": "~6.0.7",
51+
"zone.js": "~0.10.0"
5252
},
5353
"devDependencies": {
54-
"@angular/compiler-cli": "~7.2.0",
55-
"@nativescript/schematics": "~0.5.0",
56-
"@ngtools/webpack": "~7.2.0",
57-
"nativescript-dev-typescript": "~0.9.0",
58-
"nativescript-dev-webpack": "~0.24.1"
54+
"@angular/compiler-cli": "~8.2.3",
55+
"@ngtools/webpack": "~8.2.2",
56+
"nativescript-dev-webpack": "~1.1.1",
57+
"typescript": "3.4.5"
5958
}
6059
}

demo-ng/webpack.config.js

+18-31
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ module.exports = env => {
3232

3333
// Default destination inside platforms/<platform>/...
3434
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));
35-
const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS";
3635

3736
const {
3837
// The 'appPath' and 'appResourcesPath' values are fetched from
@@ -43,13 +42,15 @@ module.exports = env => {
4342

4443
// You can provide the following flags when running 'tns run android|ios'
4544
aot, // --env.aot
46-
snapshot, // --env.snapshot
45+
snapshot, // --env.snapshot,
46+
production, // --env.production
4747
uglify, // --env.uglify
4848
report, // --env.report
4949
sourceMap, // --env.sourceMap
5050
hiddenSourceMap, // --env.hiddenSourceMap
5151
hmr, // --env.hmr,
5252
unitTesting, // --env.unitTesting
53+
verbose, // --env.verbose
5354
} = env;
5455

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

6769
const ngCompilerTransformers = [];
@@ -100,8 +102,15 @@ module.exports = env => {
100102

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

105+
const itemsToClean = [`${dist}/**/*`];
106+
if (platform === "android") {
107+
itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "src", "main", "assets", "snapshots")}`);
108+
itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}`);
109+
}
110+
111+
nsWebpack.processAppComponents(appComponents, platform);
103112
const config = {
104-
mode: uglify ? "production" : "development",
113+
mode: production ? "production" : "development",
105114
context: appFullPath,
106115
externals,
107116
watchOptions: {
@@ -204,6 +213,7 @@ module.exports = env => {
204213
unitTesting,
205214
appFullPath,
206215
projectRoot,
216+
ignoredFiles: nsWebpack.getUserDefinedEntries(entries, platform)
207217
}
208218
},
209219
].filter(loader => !!loader)
@@ -253,27 +263,17 @@ module.exports = env => {
253263
// Define useful constants like TNS_WEBPACK
254264
new webpack.DefinePlugin({
255265
"global.TNS_WEBPACK": "true",
256-
"process": undefined,
266+
"process": "global.process",
257267
}),
258268
// Remove all files from the out dir.
259-
new CleanWebpackPlugin([`${dist}/**/*`]),
269+
new CleanWebpackPlugin(itemsToClean, { verbose: !!verbose }),
260270
// Copy assets to out dir. Add your own globs as needed.
261271
new CopyWebpackPlugin([
262272
{ from: { glob: "fonts/**" } },
263273
{ from: { glob: "**/*.jpg" } },
264274
{ from: { glob: "**/*.png" } },
265275
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
266-
// Generate a bundle starter script and activate it in package.json
267-
new nsWebpack.GenerateBundleStarterPlugin(
268-
// Don't include `runtime.js` when creating a snapshot. The plugin
269-
// configures the WebPack runtime to be generated inside the snapshot
270-
// module and no `runtime.js` module exist.
271-
(snapshot ? [] : ["./runtime"])
272-
.concat([
273-
"./vendor",
274-
"./bundle",
275-
])
276-
),
276+
new nsWebpack.GenerateNativeScriptEntryPointsPlugin("bundle"),
277277
// For instructions on how to set up workers with webpack
278278
// check out https://github.com/nativescript/worker-loader
279279
new NativeScriptWorkerPlugin(),
@@ -283,19 +283,6 @@ module.exports = env => {
283283
],
284284
};
285285

286-
// Copy the native app resources to the out dir
287-
// only if doing a full build (tns run/build) and not previewing (tns preview)
288-
if (!externals || externals.length === 0) {
289-
config.plugins.push(new CopyWebpackPlugin([
290-
{
291-
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
292-
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
293-
context: projectRoot
294-
},
295-
]));
296-
}
297-
298-
299286
if (report) {
300287
// Generate report files for bundles content
301288
config.plugins.push(new BundleAnalyzerPlugin({

0 commit comments

Comments
 (0)