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

feat: ensure unique usage #75

Closed
wants to merge 2 commits into from
Closed

Conversation

hulkish
Copy link
Contributor

@hulkish hulkish commented Jul 8, 2017

Closes #72

@hulkish hulkish force-pushed the hulkish-ForceUniqueUsage branch from 4995ddf to 214e65e Compare July 8, 2017 12:59
src/index.js Outdated
@@ -149,7 +149,10 @@ class UglifyJsPlugin {
}

apply(compiler) {
const requestShortener = new RequestShortener(compiler.context);
if (UglifyJsPlugin.appliedCompilers.has(compiler)) return;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe print a warning to notify users to check their setup nevertheless

return this.emitWarning(`
⚠️  UglifyJS Plugin\n
The plugin seems to be applied mutliple times, this can slow down your build times significantly.
Please check your `webpack.config.js`. Did you use 'webpack -p' and added the plugin manually?
`)

Wording can be improved of course :)

I this there no 'simpler' way in achieving this ? 🙃

src/index.js Outdated
@@ -280,4 +283,11 @@ class UglifyJsPlugin {
}
}

Object.defineProperty(UglifyJsPlugin, 'appliedCompilers', {
Copy link
Member

Choose a reason for hiding this comment

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

Whats the difference between

Object.defineProperty(UglifyJSPlugin. 'appliedCompilers', {...})

&&

UglifyJSPlugin.appliedCompliers = new WeakSet()

?

// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`compiler plugin count 1`] = `
Object {
Copy link
Member

Choose a reason for hiding this comment

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

Is this the compiler {Object} ?

@hulkish hulkish force-pushed the hulkish-ForceUniqueUsage branch from 214e65e to e1ae04a Compare July 10, 2017 01:12
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.

2 participants