-
-
Notifications
You must be signed in to change notification settings - Fork 590
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
chore(add-generator): changed the naming of the plugin in config file #893
Conversation
Changed the naming of the plugin to better and standard and bug free name in add-generator in plugin question
Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon. |
There was a problem hiding this 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
packages/generators/add-generator.ts
Outdated
0, | ||
normalizePluginName.charAt(0).toUpperCase() | ||
); | ||
let myPluginNameArray = answerToAction.actionAnswer.split("-") |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay 👍
Thanks @anikethsaha, |
@rishabh3112 true! |
@ematipico yeah I can do that. |
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
cc @ematipico @evenstensberg , I made those changes. PTAL |
Added if stmt for not doing anything when native plugins comes-in Also Changed the test
fix the indentation
changed the loop
assigned length of the plugin to a constant
@evenstensberg Thanks for your update. I labeled the Pull Request so reviewers will review it again. @ematipico Please review the new changes. |
There was a problem hiding this 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! ✅
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 likeextract-text-webpack-plugin
, it would give the plugin in config file like thisBug
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