-
Notifications
You must be signed in to change notification settings - Fork 44
refactor: rename babili
to babel-minify
#55
Conversation
Codecov Report
@@ Coverage Diff @@
## master #55 +/- ##
=======================================
- Coverage 72.91% 66% -6.92%
=======================================
Files 2 2
Lines 48 50 +2
Branches 16 17 +1
=======================================
- Hits 35 33 -2
- Misses 12 15 +3
- Partials 1 2 +1
Continue to review full report at Codecov.
|
Hi! Is there any interest on this? |
@@ -50,17 +50,16 @@ module.exports = { | |||
+ `sourceMap`: Default: uses [webpackConfig.devtool](https://webpack.js.org/configuration/devtool/). Set this to override that. | |||
+ `parserOpts`: Configure babel with special parser options. | |||
+ `babel`: Pass in a custom babel-core instead. `require("babel-core")` | |||
+ `babili`: Pass in a custom babili preset instead - `require("babel-preset-babili")`. | |||
`` | |||
+ `minifyPreset`: Pass in a custom minify preset instead - `require("babel-preset-minify")`. |
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 about minify|minifier
|| preset
instead?
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.
minify or minifier sends wrong information. For example, when require("babel-minify")
is passed. IMO, minifyPreset
says that it's babel-preset-minify
and is clear.
README.md
Outdated
module.exports = { | ||
entry: //..., | ||
output: //..., | ||
plugins: [ | ||
new BabiliPlugin(babiliOptions, overrides) | ||
new MinifyPlugin(minifyOptions, overrides) |
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.
new MinifyPlugin(minifyOptions, pluginOptions)
overrides
=> pluginOptions
?
src/index.js
Outdated
this.babiliOpts = babiliOpts; | ||
export default class BabelMinifyPlugin { | ||
constructor(minifyOpts = {}, options = {}) { | ||
this.minifyOpts = minifyOpts; |
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.
constructor (options) {
this.options = {
parser: ...parserOptions
preset: require('babel-preset-babili')
minify: ...minifierOptions
babel: require('babel-core'),
comments: '',
sourceMap: ''
}
}
?
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.
Maybe instead of preset
&& minify
just
=> preset: [ require('babel-preset-minify'), { ...minifyOptions } ]
{Array}
=> preset: { ...minifyOptions }
{Object}
Thanks @michael-ciniawsky for fast review :) |
I added the @boopathi How important is it being able to customize the I started porting |
@michael-ciniawsky let's fix all issues related to cache and parallelization in |
babili
to babel-minify
babili
to babel-minify
babili
to babel-minify
babili
to babel-minify
babili
to babel-minify
I'll be publishing it as |
src/index.js
Outdated
|
||
apply(compiler) { | ||
const { babiliOpts, options } = this; | ||
// alias for undefined / void 0 :( |
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.
:D Please use // eslint-disable-next-line
(L12)
src/index.js
Outdated
// compiler.options.devtool overrides options.sourceMap if NOT set | ||
// so we set it to undefined/void 0 as the default value | ||
sourceMap: getDefault(pluginOpts.sourceMap, undef), | ||
jsregex: pluginOpts.jsregex || /\.js($|\?)/i, |
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.
test
is better imho, since webpack uses this name all over the place for filtering files :)
src/index.js
Outdated
|
||
const jsregex = options.test || /\.js($|\?)/i; | ||
const commentsRegex = typeof options.comments === 'undefined' ? /@preserve|@licen(s|c)e/ : options.comments; | ||
function getDefault(actualValue, defaultValue) { |
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.
// eslint-disable-next-line
const getDefault = (actual, default) => actual !== undefined ? actual : default
src/index.js
Outdated
|
||
// not a ternary because prettier puts test and consequent on different lines | ||
// and webpack-defaults has a rule not to do the same :( | ||
if (result.map) { |
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.
// eslint-disable ${rule-name} :)
compilation.assets[file] = result.map
? new SourceMapSource(result.code, file, result.map, input, inputSourceMap);
: new RawSource(result.code);
src/index.js
Outdated
this.options = { | ||
parserOpts: pluginOpts.parserOpts || {}, | ||
minifyPreset: pluginOpts.minifyPreset || babelPresetMinify, | ||
minifierOpts, |
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.
nitpick 🐦 minifierOpts
=> minifyOpts
?
|
@boopathi need somebody from https://github.com/orgs/webpack-contrib/people who have |
Sry I can't, we are just grunt workers here :D Either set the |
FYI - You have access to merge, it takes owner level access to override the checks. |
I still need permission to push to master for release commits. How are release commits pushed to master in webpack-contrib? |
@boopathi Just as a question, the package is released as |
The first version will be |
OK so will wait for |
No description provided.