Skip to content
This repository has been archived by the owner on Mar 16, 2020. It is now read-only.

"mangle.exclude" doesn't seem to exclude the namespaces #77

Open
kettanaito opened this issue Jan 21, 2018 · 5 comments
Open

"mangle.exclude" doesn't seem to exclude the namespaces #77

kettanaito opened this issue Jan 21, 2018 · 5 comments

Comments

@kettanaito
Copy link

Hi. I'm using the latest version of this package - 0.2.0.

Issue

Providing mangle.exclude doesn't exclude the given class/method names from being mangled.

Minify options

new BabelMinifyPlugin({
      removeConsole: true,
      mangle: {
        topLevel: true,
        exclude: {
          /* I need to preserve the names of the classes listed below */
          'FormProvider': true,
          'Form': true,
          'connectField': true,
          'Condition': true,
          'Field': true
        }
      }
    })

Environment

  • Node: v6.9.5
  • OS: MacOS Sierra (10.12.6 (16G29))

Reproduce

  1. Clone/fork my repository.
  2. Checkout to dev/bundle-size branch if not there already.
  3. Run npm run build to build the project in production mode
  4. Examine the output bundle - excluded namespaces are still mangled.

Please help me resolve this issue. Thanks.

@alexander-akait
Copy link
Member

@kettanaito Thanks for issue, you just use invalid configuration - use minifyOptions: { ... } for mangle option, see https://github.com/webpack-contrib/babel-minify-webpack-plugin#pluginopts

@kettanaito
Copy link
Author

kettanaito commented Feb 2, 2018

@evilebottnawi thanks for the reply!

TL;DR

Please show me a missing example of how to provide these options using BabelMinifyPlugin. Thanks.

Long version

To be honest, I would like to see at least one working example. Even what you've posted right now doesn't make much sense to me:

Here's how to use the plugin from its README:

new MinifyPlugin(minifyOpts, pluginOpts)

How I'm using it:

new MinifyPlugin({
  removeConsole: true,
  mangle: { ... }
})

You suggest I should use minifyOptions, which I do - that's the Object which the plugin accepts as the first argument, isn't it?

removeConsole and removeDebugger, which are minifyOptions, if I get it correctly, work properly when passed as I am passing them. That makes it valid to assume the first Object is a minifyOptions.

Please, could you clarify this? It feels like there's no clear explanation how to pass those options.
Thanks.

P.S. I would be only glad to add the proper example of usage myself as a pull request, only explain it to me please.

@alexander-akait
Copy link
Member

@kettanaito sorry, you are right, you have valid config, i reopen issue, but seems it is not related to plugin, we just pass option to babel using babel-preset-minify

@kettanaito
Copy link
Author

kettanaito commented Feb 2, 2018

@evilebottnawi thanks!

Let's address the respective repository then, it seems things are broken. Do you mind doing so? If not, please just direct me what is a proper place to ask.

Regardless, what do you think about adding at least one real-world example to this repo? That would help a lot, from my experience.

@alexander-akait
Copy link
Member

@kettanaito agree, PR welcome, many work right now

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants