Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Mangle parameters not taken into account #749

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 13 additions & 8 deletions packages/metro-minify-terser/src/minifier.js
Expand Up @@ -33,15 +33,20 @@ function minify({code, map, reserved, config}: MinifierOptions): {
} {
const options = {
...config,
mangle: {
...config.mangle,
reserved,
},
mangle:
typeof config.mangle === 'object'
? {
...config.mangle,
reserved,
}
: config.mangle,
sourceMap: map
? {
...config.sourceMap,
content: map,
}
? typeof config.sourceMap === 'object'
? {
...config.sourceMap,
content: map,
}
: config.sourceMap
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mfbx9da4, thanks for looking into this.

I think we need just to be a bit careful around intention here - if user config is null or undefined we should respect metro's defaults, and continue to pass an object downstream.

IMO the best approach would be to check whether the user explicitly wants to disable these features with === false, and spread everything else (note that it is safe to object-spread primitives)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah great point. Updated now, let me know if that works! 🙂

: false,
};

Expand Down
22 changes: 14 additions & 8 deletions packages/metro-minify-uglify/src/minifier.js
Expand Up @@ -34,14 +34,20 @@ function minify({code, map, reserved, config}: MinifierOptions): {
} {
const options = {
...config,
mangle: {
...config.mangle,
reserved,
},
sourceMap: {
...config.sourceMap,
content: map,
},
mangle:
typeof config.mangle === 'object'
? {
...config.mangle,
reserved,
}
: config.mangle,
sourceMap:
typeof config.sourceMap === 'object'
? {
...config.sourceMap,
content: map,
}
: config.sourceMap,
};

/* $FlowFixMe(>=0.111.0 site=react_native_fb) This comment suppresses an
Expand Down