Skip to content

Commit aadc7a4

Browse files
sis0k0VladimirAmiorkov
authored andcommitted
fix(webpack): bundling with uglify (#87)
* chore: update nativescript-dev-webpack configs and deps * refactor: unify TypeScript configuration * fix(tsconfig): disable emitting of helper functions This way the global __extend, __decorate, etc. functions will be used and they won't be renamed when running webpack. This is important because the static binding generator looks for nodes with these names when traversing the js sources for native extenders. * refactor: remove unnecessary mangle exception
1 parent b7c67b5 commit aadc7a4

8 files changed

+127
-256
lines changed
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* A dynamically generated module when compiled with AoT.
3+
*/
4+
export const AppModuleNgFactory: any;

sdkAngular/app/vendor-platform.android.ts

-12
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
// Resolve JavaScript classes that extend a Java class, and need to resolve
2-
// their JavaScript module from a bundled script. For example:
3-
// NativeScriptApplication, NativeScriptActivity, etc.
4-
//
5-
// This module gets bundled together with the rest of the app code and the
6-
// `require` calls get resolved to the correct bundling import call.
7-
//
8-
// At runtime the module gets loaded *before* the rest of the app code, so code
9-
// placed here needs to be careful about its dependencies.
10-
111
require("application");
12-
132
if (!global["__snapshot"]) {
143
// In case snapshot generation is enabled these modules will get into the bundle
154
// but will not be required/evaluated.
165
// The snapshot webpack plugin will add them to the tns-java-classes.js bundle file.
176
// This way, they will be evaluated on app start as early as possible.
18-
197
require("ui/frame");
208
require("ui/frame/activity");
219
require("./main-activity.android.ts");

sdkAngular/app/vendor-platform.ios.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// There is a bug in angular: https://github.com/angular/angular-cli/pull/8589/files
2+
// Legendary stuff, its webpack plugin pretty much doesn't work with empty TypeScript files in v1.8.3
3+
void 0;

sdkAngular/app/vendor.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// Snapshot the ~/app.css and the theme
2+
const application = require("application");
3+
require("ui/styling/style-scope");
4+
const appCssContext = require.context("~/", false, /^\.\/app\.(css|scss|less|sass)$/);
5+
global.registerWebpackModules(appCssContext);
6+
application.loadAppCss();
7+
18
require("./vendor-platform");
29

310
require("reflect-metadata");
@@ -11,11 +18,3 @@ require("@angular/router");
1118
require("nativescript-angular/platform-static");
1219
require("nativescript-angular/forms");
1320
require("nativescript-angular/router");
14-
15-
require("nativescript-pro-ui/autocomplete/angular");
16-
require("nativescript-pro-ui/calendar/angular");
17-
require("nativescript-pro-ui/chart/angular");
18-
require("nativescript-pro-ui/dataform/angular");
19-
require("nativescript-pro-ui/gauges/angular");
20-
require("nativescript-pro-ui/listview/angular");
21-
require("nativescript-pro-ui/sidedrawer/angular");

sdkAngular/package.json

+12-11
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@
3737
},
3838
"devDependencies": {
3939
"@angular/compiler-cli": "~5.0.0",
40-
"@ngtools/webpack": "~1.5.3",
40+
"@ngtools/webpack": "~1.8.2",
4141
"babel-traverse": "6.24.1",
4242
"babel-types": "6.24.1",
4343
"babylon": "6.17.0",
4444
"chai": "^3.5.0",
4545
"codelyzer": "^3.0.0",
4646
"copy-webpack-plugin": "~4.0.1",
47-
"extract-text-webpack-plugin": "3.0.0",
47+
"css-loader": "~0.28.7",
48+
"extract-text-webpack-plugin": "~3.0.0",
4849
"filewalker": "0.1.3",
4950
"karma": "^1.6.0",
5051
"karma-chai": "^0.1.0",
@@ -55,25 +56,25 @@
5556
"nativescript-css-loader": "~0.26.0",
5657
"nativescript-dev-typescript": "0.5.1",
5758
"nativescript-dev-webpack": "next",
59+
"nativescript-worker-loader": "~0.8.1",
5860
"raw-loader": "~0.5.1",
59-
"resolve-url-loader": "~2.0.2",
61+
"resolve-url-loader": "~2.1.0",
6062
"tns-platform-declarations": "next",
61-
"tslint": "^5.1.0",
6263
"tslib": "1.7.1",
64+
"tslint": "^5.1.0",
6365
"typescript": "~2.4.2",
64-
"webpack": "3.1.0",
66+
"webpack": "~3.8.1",
6567
"webpack-bundle-analyzer": "^2.8.2",
66-
"webpack-sources": "~1.0.1",
67-
"nativescript-worker-loader": "~0.8.1"
68+
"webpack-sources": "~1.0.1"
6869
},
6970
"scripts": {
70-
"ns-bundle": "ns-bundle",
7171
"tslint": "tslint --project tsconfig.json --config tslint.json",
72-
"publish-ios-bundle": "npm run ns-bundle --ios --publish-app",
73-
"generate-android-snapshot": "generate-android-snapshot --targetArchs arm,arm64,ia32 --install",
72+
"ns-bundle": "ns-bundle",
7473
"start-android-bundle": "npm run ns-bundle --android --run-app",
7574
"start-ios-bundle": "npm run ns-bundle --ios --run-app",
7675
"build-android-bundle": "npm run ns-bundle --android --build-app",
77-
"build-ios-bundle": "npm run ns-bundle --ios --build-app"
76+
"build-ios-bundle": "npm run ns-bundle --ios --build-app",
77+
"publish-ios-bundle": "npm run ns-bundle --ios --publish-app",
78+
"generate-android-snapshot": "generate-android-snapshot --targetArchs arm,arm64,ia32 --install"
7879
}
7980
}

sdkAngular/tsconfig.aot.json

-39
This file was deleted.

sdkAngular/tsconfig.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"removeComments": false,
88
"watch": false,
99
"noLib": false,
10+
"noEmitHelpers": true,
1011
"preserveConstEnums": true,
1112
"emitDecoratorMetadata": true,
1213
"suppressImplicitAnyIndexErrors": true,
@@ -30,7 +31,6 @@
3031
],
3132
"exclude": [
3233
"node_modules",
33-
"platforms",
34-
"**/*.aot.ts"
34+
"platforms"
3535
]
36-
}
36+
}

0 commit comments

Comments
 (0)