Skip to content
This repository was archived by the owner on Dec 5, 2019. It is now read-only.

fix(index): exclude is ignored (options.exclude) #164

Merged
merged 1 commit into from
Nov 15, 2017
Merged

fix(index): exclude is ignored (options.exclude) #164

merged 1 commit into from
Nov 15, 2017

Conversation

rszewczyk
Copy link
Contributor

A simple demo of the problem can be found here.

The expected behavior is that chunks with a filename that match the given pattern will be excluded from uglify. This was the behavior exhibited by 0.4.6. The actual behavior is that all chunks are uglified.

It looks like the problem is that the options used to filter what chunks are processed, do not include the exclude configuration passed to the plugin constructor.

@jsf-clabot
Copy link

jsf-clabot commented Nov 15, 2017

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Looks good!

@alexander-akait alexander-akait added this to the 1.1.0 milestone Nov 15, 2017
@michael-ciniawsky michael-ciniawsky changed the title fix: exclude option is ignored fix(index): exclude is ignored (options.exclude) Nov 15, 2017
Copy link
Member

@michael-ciniawsky michael-ciniawsky left a comment

Choose a reason for hiding this comment

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

Thx awesome 👍 this was one of the blockers to update uglify for webpack v4.0.0

@everdimension
Copy link

This fix doesn't seem to work for me.

Could it be that it is because the file I wish to exclude is in node_modules folder?

@alexander-akait
Copy link
Member

@everdimension can you provide configuration?

@everdimension
Copy link

Well I wished I wouldn't have to make a demo repo :) But I can try later today.

But in short for now here's part of my module config:

module: {
  rules: [
    /** ...other rules... */
    {
      test: /\.js$/,
      use: [
        {
          loader: 'babel-loader',
        },
      ],
      include: path.resolve(__dirname, 'src'),
    },
  ],
}

Here are uglifyjsplugin options:

new UglifyJSPlugin({
  exclude: /ReactChartIQ\.translations.*\.js$/i,
  uglifyOptions: {
    ie8: false,
    warnings: false,
    sourceMap: true
  },
})

These work in 1.0.0-beta.1 (with according options shape)

@alexander-akait
Copy link
Member

@everdimension strange, minimum test repo will be very helpful

@rszewczyk
Copy link
Contributor Author

I think think the issue is that the plugin processes output files not input files. I'm not sure about the beta, but this is the same behavior as 0.4.6.

@everdimension I'm not sure about your use case - but we have some legacy code that can't be minified, so the way we did it (with the current version of the plugin - 0.4.6) was to group all the code into it's own chunk by defining an entry point just for those legacy files.

@alexander-akait
Copy link
Member

@rszewczyk yes, you are right
@everdimension move you code to entry and use exclude

@alexander-akait
Copy link
Member

test, include and exclude options works similar BannerPlugin (https://github.com/webpack/webpack/blob/6a26e9ba7f7f1be7e76054f219bf1e094f2c3264/lib/BannerPlugin.js)

@michael-ciniawsky
Copy link
Member

Yep, this 'only' excludes compilation.assets (output), you can't exclude particular modules

@michael-ciniawsky michael-ciniawsky removed this from the 1.0.3 milestone Nov 17, 2017
@everdimension
Copy link

It's not a particular module, i'm trying to exclude a filename within a module

@michael-ciniawsky
Copy link
Member

it's not particular module <=> within a modulein the same sentence should ring a bell 😛(the import is/will be a module on it's own). At the point in the webpack lifecycle (hook) where uglifyjs-webpack-plugin is applied there are only the output files left without an easy way to add filters on a 'module-level' for particular modules within these assets. Why do you need this, what is the use case ?

@everdimension
Copy link

in the same sentence should ring a bell

What?

I have a particular output file name. Otherwise it wouldn't have worked before either.

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

Successfully merging this pull request may close these issues.

5 participants