@@ -4,7 +4,7 @@ var path = require("path");
4
4
5
5
//HACK: changes the JSONP chunk eval function to `global["nativescriptJsonp"]`
6
6
// applied to tns-java-classes.js only
7
- exports . NativeScriptJsonpPlugin = function ( options ) {
7
+ exports . NativeScriptJsonpPlugin = function ( options ) {
8
8
} ;
9
9
10
10
exports . NativeScriptJsonpPlugin . prototype . apply = function ( compiler ) {
@@ -27,7 +27,42 @@ exports.NativeScriptJsonpPlugin.prototype.apply = function (compiler) {
27
27
} ) ;
28
28
} ;
29
29
30
- exports . GenerateBundleStarterPlugin = function ( bundles ) {
30
+ exports . ExcludeUnusedElementsPlugin = function ( ) {
31
+ } ;
32
+
33
+ exports . ExcludeUnusedElementsPlugin . prototype . apply = function ( compiler ) {
34
+ compiler . plugin ( "normal-module-factory" , function ( nmf ) {
35
+ nmf . plugin ( "before-resolve" , function ( result , callback ) {
36
+ if ( ! result ) {
37
+ return callback ( ) ;
38
+ }
39
+
40
+ if ( result . request === "globals" || result . request === "ui/core/view" ) {
41
+ return callback ( null , result ) ;
42
+ }
43
+
44
+ if ( result . context . indexOf ( "tns-core-modules" ) === - 1 ) {
45
+ if ( result . contextInfo . issuer &&
46
+ result . contextInfo . issuer . indexOf ( "element-registry" ) !== - 1 && global [ "ELEMENT_REGISTRY" ] &&
47
+ ! global [ "ELEMENT_REGISTRY" ] [ result . request ] ) {
48
+ return callback ( ) ;
49
+
50
+ } else {
51
+ return callback ( null , result ) ;
52
+ }
53
+ }
54
+
55
+ if ( result . contextInfo . issuer . indexOf ( "bundle-entry-points" ) !== - 1 && global [ "ELEMENT_REGISTRY" ] &&
56
+ ! global [ "ELEMENT_REGISTRY" ] [ result . request ] ) {
57
+ return callback ( ) ;
58
+ }
59
+
60
+ return callback ( null , result ) ;
61
+ } ) ;
62
+ } ) ;
63
+ } ;
64
+
65
+ exports . GenerateBundleStarterPlugin = function ( bundles ) {
31
66
this . bundles = bundles ;
32
67
} ;
33
68
@@ -45,22 +80,22 @@ exports.GenerateBundleStarterPlugin.prototype = {
45
80
cb ( ) ;
46
81
} ) ;
47
82
} ,
48
- generatePackageJson : function ( ) {
83
+ generatePackageJson : function ( ) {
49
84
var packageJsonPath = path . join ( this . webpackContext , "package.json" ) ;
50
85
var packageData = JSON . parse ( fs . readFileSync ( packageJsonPath , "utf8" ) ) ;
51
86
packageData . main = "starter" ;
52
87
53
88
return new sources . RawSource ( JSON . stringify ( packageData , null , 4 ) ) ;
54
89
} ,
55
- generateStarterModule : function ( ) {
56
- var moduleSource = this . bundles . map ( function ( bundle ) {
90
+ generateStarterModule : function ( ) {
91
+ var moduleSource = this . bundles . map ( function ( bundle ) {
57
92
return "require(\"" + bundle + "\");" ;
58
93
} ) . join ( "\n" ) ;
59
94
return new sources . RawSource ( moduleSource ) ;
60
95
} ,
61
96
} ;
62
97
63
- exports . getEntryModule = function ( ) {
98
+ exports . getEntryModule = function ( ) {
64
99
var projectDir = path . dirname ( path . dirname ( __dirname ) ) ;
65
100
var appPackageJsonPath = path . join ( projectDir , "app" , "package.json" ) ;
66
101
var appPackageJson = JSON . parse ( fs . readFileSync ( appPackageJsonPath , "utf8" ) ) ;
@@ -70,12 +105,12 @@ exports.getEntryModule = function() {
70
105
return appPackageJson . main . replace ( / \. j s $ / i, "" ) ;
71
106
} ;
72
107
73
- exports . getAppPath = function ( platform ) {
108
+ exports . getAppPath = function ( platform ) {
74
109
var projectDir = path . dirname ( path . dirname ( __dirname ) ) ;
75
110
76
111
if ( / i o s / i. test ( platform ) ) {
77
112
var appName = path . basename ( projectDir ) ;
78
- var sanitizedName = appName . split ( "" ) . filter ( function ( c ) {
113
+ var sanitizedName = appName . split ( "" ) . filter ( function ( c ) {
79
114
return / [ a - z A - Z 0 - 9 ] / . test ( c ) ;
80
115
} ) . join ( "" ) ;
81
116
return "platforms/ios/" + sanitizedName + "/app" ;
0 commit comments