Skip to content

Commit c005c36

Browse files
authored
[MOO-2070]: Conditional terser configuration for react-native-reanimated compatibility MX10 (#366)
2 parents 021801e + 66e178d commit c005c36

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
diff --git a/node_modules/@mendix/pluggable-widgets-tools/configs/rollup.config.native.js b/node_modules/@mendix/pluggable-widgets-tools/configs/rollup.config.native.js
2+
index bb8cc3a..34e0877 100644
3+
--- a/node_modules/@mendix/pluggable-widgets-tools/configs/rollup.config.native.js
4+
+++ b/node_modules/@mendix/pluggable-widgets-tools/configs/rollup.config.native.js
5+
@@ -169,6 +169,17 @@ export default async args => {
6+
return result;
7+
8+
function getCommonPlugins(config) {
9+
+ const hasReanimated = (() => {
10+
+ try {
11+
+ const packageJson = require(join(sourcePath, "package.json"));
12+
+ return !!(
13+
+ (packageJson.dependencies && packageJson.dependencies["react-native-reanimated"]) ||
14+
+ (packageJson.peerDependencies && packageJson.peerDependencies["react-native-reanimated"])
15+
+ );
16+
+ } catch {
17+
+ return false;
18+
+ }
19+
+ })();
20+
return [
21+
nodeResolve({ preferBuiltins: false, mainFields: ["module", "browser", "main"] }),
22+
isTypescript
23+
@@ -223,7 +234,21 @@ export default async args => {
24+
})
25+
: null,
26+
image(),
27+
- production ? terser({ mangle: false }) : null,
28+
+ production ? terser(hasReanimated
29+
+ ? {
30+
+ mangle: false,
31+
+ compress: {
32+
+ defaults: false,
33+
+ inline: false,
34+
+ reduce_funcs: false,
35+
+ side_effects: false,
36+
+ },
37+
+ keep_fnames: true,
38+
+ keep_classnames: true,
39+
+ module: false,
40+
+ format: { comments: false }
41+
+ }
42+
+ : { mangle: false }) : null,
43+
// We need to create .mpk and copy results to test project after bundling is finished.
44+
// In case of a regular build is it is on `writeBundle` of the last config we define
45+
// (since rollup processes configs sequentially). But in watch mode rollup re-bundles only

0 commit comments

Comments
 (0)