expo-build-properties 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,12 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.5.2 — 2023-04-03
14
+
15
+ ### 🎉 New features
16
+
17
+ - Added `enableShrinkResourcesInReleaseBuilds` property to enable Android `shrinkResources` build feature. ([#21911](https://github.com/expo/expo/pull/21911) by [@kudo](https://github.com/kudo))
18
+
13
19
  ## 0.5.1 — 2023-02-09
14
20
 
15
21
  ### 🎉 New features
package/build/android.js CHANGED
@@ -54,6 +54,10 @@ exports.withAndroidBuildProperties = createBuildGradlePropsConfigPlugin([
54
54
  propName: 'android.enableProguardInReleaseBuilds',
55
55
  propValueGetter: (config) => config.android?.enableProguardInReleaseBuilds?.toString(),
56
56
  },
57
+ {
58
+ propName: 'android.enableShrinkResourcesInReleaseBuilds',
59
+ propValueGetter: (config) => config.android?.enableShrinkResourcesInReleaseBuilds?.toString(),
60
+ },
57
61
  ], 'withAndroidBuildProperties');
58
62
  const withAndroidFlipper = (config, props) => {
59
63
  const ANDROID_FLIPPER_KEY = 'FLIPPER_VERSION';
@@ -46,6 +46,11 @@ export interface PluginConfigTypeAndroid {
46
46
  * Enable [Proguard or R8](https://developer.android.com/studio/build/shrink-code) in release builds to obfuscate Java code and reduce app size.
47
47
  */
48
48
  enableProguardInReleaseBuilds?: boolean;
49
+ /**
50
+ * Enable [`shrinkResources`](https://developer.android.com/studio/build/shrink-code#shrink-resources) in release builds to remove unused resources from the app.
51
+ * This property should be used in combination with `enableProguardInReleaseBuilds`.
52
+ */
53
+ enableShrinkResourcesInReleaseBuilds?: boolean;
49
54
  /**
50
55
  * Append custom [Proguard rules](https://www.guardsquare.com/manual/configuration/usage) to **android/app/proguard-rules.pro**.
51
56
  */
@@ -55,10 +60,11 @@ export interface PluginConfigTypeAndroid {
55
60
  */
56
61
  packagingOptions?: PluginConfigTypeAndroidPackagingOptions;
57
62
  /**
58
- * Change the [Flipper](https://fbflipper.com/) version when running your app on Android.
59
- * Flipper is by default enabled with the version that comes bundled with react-native.
60
- * However, you can set the `flipper` property to a semver string and specify an
61
- * alternate Flipper version.
63
+ * By default, Flipper is enabled with the version that comes bundled with `react-native`.
64
+ *
65
+ * Use this to change the [Flipper](https://fbflipper.com/) version when
66
+ * running your app on Android. You can set the `flipper` property to a
67
+ * semver string and specify an alternate Flipper version.
62
68
  */
63
69
  flipper?: string;
64
70
  }
@@ -81,16 +87,17 @@ export interface PluginConfigTypeIos {
81
87
  * Enable [`use_frameworks!`](https://guides.cocoapods.org/syntax/podfile.html#use_frameworks_bang)
82
88
  * in `Podfile` to use frameworks instead of static libraries for Pods.
83
89
  *
84
- * Note: You cannot use `useFrameworks` and `flipper` at the same time
90
+ * > You cannot use `useFrameworks` and `flipper` at the same time , and
91
+ * doing so will generate an error.
85
92
  */
86
93
  useFrameworks?: 'static' | 'dynamic';
87
94
  /**
88
95
  * Enable [Flipper](https://fbflipper.com/) when running your app on iOS in
89
96
  * Debug mode. Setting `true` enables the default version of Flipper, while
90
97
  * setting a semver string will enable a specific version of Flipper you've
91
- * declared in your package.json. The default for this configuration is `false`.
98
+ * declared in your **package.json**. The default for this configuration is `false`.
92
99
  *
93
- * Note: You cannot use `flipper` at the same time as `useFrameworks`, and
100
+ * > You cannot use `flipper` at the same time as `useFrameworks`, and
94
101
  * doing so will generate an error.
95
102
  */
96
103
  flipper?: boolean | string;
@@ -34,6 +34,7 @@ const schema = {
34
34
  buildToolsVersion: { type: 'string', nullable: true },
35
35
  kotlinVersion: { type: 'string', nullable: true },
36
36
  enableProguardInReleaseBuilds: { type: 'boolean', nullable: true },
37
+ enableShrinkResourcesInReleaseBuilds: { type: 'boolean', nullable: true },
37
38
  extraProguardRules: { type: 'string', nullable: true },
38
39
  flipper: {
39
40
  type: 'string',
@@ -130,6 +131,10 @@ function validateConfig(config) {
130
131
  if (config?.ios?.flipper !== undefined && config?.ios?.useFrameworks !== undefined) {
131
132
  throw new Error('`ios.flipper` cannot be enabled when `ios.useFrameworks` is set.');
132
133
  }
134
+ if (config.android?.enableShrinkResourcesInReleaseBuilds === true &&
135
+ config.android?.enableProguardInReleaseBuilds !== true) {
136
+ throw new Error('`android.enableShrinkResourcesInReleaseBuilds` requires `android.enableProguardInReleaseBuilds` to be enabled.');
137
+ }
133
138
  return config;
134
139
  }
135
140
  exports.validateConfig = validateConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-build-properties",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Config plugin to customize native build properties on prebuild",
5
5
  "main": "build/withBuildProperties.js",
6
6
  "types": "build/withBuildProperties.d.ts",
@@ -40,5 +40,5 @@
40
40
  "peerDependencies": {
41
41
  "expo": "*"
42
42
  },
43
- "gitHead": "1f8a6a09570fd451378565ca34933018ce48454e"
43
+ "gitHead": "014aa056080fd88a11b09b5be7c3ba078fbec7d0"
44
44
  }
package/src/android.ts CHANGED
@@ -59,6 +59,10 @@ export const withAndroidBuildProperties = createBuildGradlePropsConfigPlugin<Plu
59
59
  propName: 'android.enableProguardInReleaseBuilds',
60
60
  propValueGetter: (config) => config.android?.enableProguardInReleaseBuilds?.toString(),
61
61
  },
62
+ {
63
+ propName: 'android.enableShrinkResourcesInReleaseBuilds',
64
+ propValueGetter: (config) => config.android?.enableShrinkResourcesInReleaseBuilds?.toString(),
65
+ },
62
66
  ],
63
67
  'withAndroidBuildProperties'
64
68
  );
@@ -66,6 +66,11 @@ export interface PluginConfigTypeAndroid {
66
66
  * Enable [Proguard or R8](https://developer.android.com/studio/build/shrink-code) in release builds to obfuscate Java code and reduce app size.
67
67
  */
68
68
  enableProguardInReleaseBuilds?: boolean;
69
+ /**
70
+ * Enable [`shrinkResources`](https://developer.android.com/studio/build/shrink-code#shrink-resources) in release builds to remove unused resources from the app.
71
+ * This property should be used in combination with `enableProguardInReleaseBuilds`.
72
+ */
73
+ enableShrinkResourcesInReleaseBuilds?: boolean;
69
74
  /**
70
75
  * Append custom [Proguard rules](https://www.guardsquare.com/manual/configuration/usage) to **android/app/proguard-rules.pro**.
71
76
  */
@@ -76,10 +81,11 @@ export interface PluginConfigTypeAndroid {
76
81
  packagingOptions?: PluginConfigTypeAndroidPackagingOptions;
77
82
 
78
83
  /**
79
- * Change the [Flipper](https://fbflipper.com/) version when running your app on Android.
80
- * Flipper is by default enabled with the version that comes bundled with react-native.
81
- * However, you can set the `flipper` property to a semver string and specify an
82
- * alternate Flipper version.
84
+ * By default, Flipper is enabled with the version that comes bundled with `react-native`.
85
+ *
86
+ * Use this to change the [Flipper](https://fbflipper.com/) version when
87
+ * running your app on Android. You can set the `flipper` property to a
88
+ * semver string and specify an alternate Flipper version.
83
89
  */
84
90
  flipper?: string;
85
91
  }
@@ -104,7 +110,8 @@ export interface PluginConfigTypeIos {
104
110
  * Enable [`use_frameworks!`](https://guides.cocoapods.org/syntax/podfile.html#use_frameworks_bang)
105
111
  * in `Podfile` to use frameworks instead of static libraries for Pods.
106
112
  *
107
- * Note: You cannot use `useFrameworks` and `flipper` at the same time
113
+ * > You cannot use `useFrameworks` and `flipper` at the same time , and
114
+ * doing so will generate an error.
108
115
  */
109
116
  useFrameworks?: 'static' | 'dynamic';
110
117
 
@@ -112,9 +119,9 @@ export interface PluginConfigTypeIos {
112
119
  * Enable [Flipper](https://fbflipper.com/) when running your app on iOS in
113
120
  * Debug mode. Setting `true` enables the default version of Flipper, while
114
121
  * setting a semver string will enable a specific version of Flipper you've
115
- * declared in your package.json. The default for this configuration is `false`.
122
+ * declared in your **package.json**. The default for this configuration is `false`.
116
123
  *
117
- * Note: You cannot use `flipper` at the same time as `useFrameworks`, and
124
+ * > You cannot use `flipper` at the same time as `useFrameworks`, and
118
125
  * doing so will generate an error.
119
126
  */
120
127
  flipper?: boolean | string;
@@ -157,6 +164,7 @@ const schema: JSONSchemaType<PluginConfigType> = {
157
164
  kotlinVersion: { type: 'string', nullable: true },
158
165
 
159
166
  enableProguardInReleaseBuilds: { type: 'boolean', nullable: true },
167
+ enableShrinkResourcesInReleaseBuilds: { type: 'boolean', nullable: true },
160
168
  extraProguardRules: { type: 'string', nullable: true },
161
169
 
162
170
  flipper: {
@@ -266,5 +274,14 @@ export function validateConfig(config: any): PluginConfigType {
266
274
  throw new Error('`ios.flipper` cannot be enabled when `ios.useFrameworks` is set.');
267
275
  }
268
276
 
277
+ if (
278
+ config.android?.enableShrinkResourcesInReleaseBuilds === true &&
279
+ config.android?.enableProguardInReleaseBuilds !== true
280
+ ) {
281
+ throw new Error(
282
+ '`android.enableShrinkResourcesInReleaseBuilds` requires `android.enableProguardInReleaseBuilds` to be enabled.'
283
+ );
284
+ }
285
+
269
286
  return config;
270
287
  }