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

chore(add-generator): changed the naming of the plugin in config file #893

Merged
merged 9 commits into from May 30, 2019
Merged

chore(add-generator): changed the naming of the plugin in config file #893

merged 9 commits into from May 30, 2019

Conversation

anikethsaha
Copy link
Member

@anikethsaha anikethsaha commented May 24, 2019

What kind of change does this PR introduce?
refactoring/bugfix

Did you add tests for your changes?
Yes

If relevant, did you update the documentation?
NA

Summary
Changed the naming of the current naming of the webpack plugin in the add-generator to a better and standard way of naming. The earlier one was creating error name when passed something like extract-text-webpack-plugin, it would give the plugin in config file like this

Bug

	plugins: new Extract() - textPlugin,

With this refractor
It will output the config file plugin with this

plugins: new ExtractTextWebpackPlugin(),

Does this PR introduce a breaking change?

No

Other information
NA

Changed the naming of the plugin to better and standard and bug free
name in add-generator in plugin question
@webpack-bot
Copy link

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

Copy link
Contributor

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

A suggestion for the refactor

0,
normalizePluginName.charAt(0).toUpperCase()
);
let myPluginNameArray = answerToAction.actionAnswer.split("-")
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you extract this new logic into a separate function and test it against few different plugins? There are the native ones too webpack.DefinePlugin.

Copy link
Member

Choose a reason for hiding this comment

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

+1, this could quickly turn into a mess

Copy link
Member

Choose a reason for hiding this comment

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

^ What I mean by that is that like @ematipico is saying, is that it might be hard to verify that this works unless we test it thoroughly. A better thing to do, would be to abstract the logic so we can run unit tests on it and make sure that it is working as expected.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, So Should I add it in utils and write tests for it. If it's fine? @evenstensberg @ematipico . Just the naming method

Copy link
Member

Choose a reason for hiding this comment

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

Probably nice idea, or to add it within the generator itself if it's only used here

Copy link
Member Author

Choose a reason for hiding this comment

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

@evenstensberg Yeah....I was talking about the utils folder inside the generators package. Will add it there with test then

Copy link
Member

Choose a reason for hiding this comment

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

That's a great location. Go for it

Copy link
Member Author

Choose a reason for hiding this comment

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

okay 👍

@rishabh3112
Copy link
Member

Thanks @anikethsaha,
Some Bug fixes and refactoring of add generator is underway at #843. As add generator is written in async/await now, this change may need a rework, else will cause merge conflict.

@anikethsaha
Copy link
Member Author

@rishabh3112 true!
I guess I can wait for that PR to merge , Then I will rebase this and resolve the conflict manually if this is fine!...what say?

@anikethsaha
Copy link
Member Author

@ematipico yeah I can do that.
Actually I tested with those , it will simply change the first most char of that name.
If you want I can add it in utils then can add tests for that. Is it fine?

Added generatePluginName in generators/utils/plugins.ts and also moved the
replaceAt method from add-generator.ts to generators/utils/plugins.ts.
Added tests for the plugin name method
@anikethsaha
Copy link
Member Author

cc @ematipico @evenstensberg , I made those changes. PTAL

Added if stmt for not doing anything when native plugins comes-in
Also Changed the test
changed the loop
@webpack-bot
Copy link

@evenstensberg Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@ematipico Please review the new changes.

Copy link
Member

@evenstensberg evenstensberg left a comment

Choose a reason for hiding this comment

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

lgtm, nice work here! ✅

@evenstensberg evenstensberg merged commit de9c89c into webpack:master May 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants