Skip to content
This repository has been archived by the owner on Mar 16, 2020. It is now read-only.

refactor: rename babili to babel-minify #55

Merged
merged 4 commits into from
Aug 17, 2017
Merged

refactor: rename babili to babel-minify #55

merged 4 commits into from
Aug 17, 2017

Conversation

boopathi
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Aug 16, 2017

Codecov Report

Merging #55 into master will decrease coverage by 6.91%.
The diff coverage is 63.88%.

Impacted file tree graph

@@           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
Impacted Files Coverage Δ
src/index.js 67.34% <63.88%> (-7.13%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d0a724c...d788353. Read the comment docs.

@pi0
Copy link

pi0 commented Aug 16, 2017

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")`.
Copy link
Member

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?

Copy link
Member Author

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)
Copy link
Member

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;
Copy link
Member

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: ''     
  }
}

?

Copy link
Member

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}

@pi0
Copy link

pi0 commented Aug 16, 2017

Thanks @michael-ciniawsky for fast review :)

@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Aug 16, 2017

I added the semver:major label to indicate it as a breaking change, but not really important since it will be publish under a new name on npm anyways :)

@boopathi How important is it being able to customize the babel & babel-preset-minify version via options ? :) What about a peerDependency instead?

I started porting parallelization support for this plugin from uglifyjs-webpack-plugin and finish it after has PR has landed :D

@alexander-akait
Copy link
Member

@michael-ciniawsky let's fix all issues related to cache and parallelization in uglifyjs-webpack-plugin (and add tests) and we can implement same algorithm here 👍

@michael-ciniawsky michael-ciniawsky changed the title Rename babili to babel-minify refactor: rename babili to babel-minify Aug 16, 2017
@michael-ciniawsky michael-ciniawsky changed the title refactor: rename babili to babel-minify refactor(src/index): rename babili to babel-minify Aug 16, 2017
@michael-ciniawsky michael-ciniawsky changed the title refactor(src/index): rename babili to babel-minify refactor: rename babili to babel-minify Aug 16, 2017
@boopathi
Copy link
Member Author

boopathi commented Aug 16, 2017

@boopathi How important is it being able to customize the babel & babel-preset-minify version via options ? :) What about a peerDependency instead?

  • Babel7 is in alpha now and almost everyone uses babel 6 in their toolchain. So it is important to have the ability to configure babel - i.e use babel7 for minification and babel6 for other transpilation or vice-versa.
  • babel and babel-minify are dependencies (and not peer deps) to have a good default and is the common case.

I added the semver:major label to indicate it as a breaking change, but not really important since it will be publish under a new name on npm anyways :)

I'll be publishing it as 0.2.0, to use the same version numbers as babel-minify.

src/index.js Outdated

apply(compiler) {
const { babiliOpts, options } = this;
// alias for undefined / void 0 :(
Copy link
Member

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,
Copy link
Member

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) {
Copy link
Member

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) {
Copy link
Member

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,
Copy link
Member

Choose a reason for hiding this comment

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

nitpick 🐦 minifierOpts => minifyOpts ?

@boopathi
Copy link
Member Author

  1. I don't have permission to merge with failing checks. Can someone merge this?
  2. Can someone give me push access to master to push release commits?

@alexander-akait
Copy link
Member

@boopathi need somebody from https://github.com/orgs/webpack-contrib/people who have Owner 😞

@michael-ciniawsky
Copy link
Member

Sry I can't, we are just grunt workers here :D Either set the status: Approved && pr: Merge ready labels or ping either (@)d3viant0ne (@)bebraw (@)TheLarkInn (@)SpaceK33z (@)jhnns (@)sokra to give you the appropiated access since you are lead maintainer here 😛

@joshwiens joshwiens merged commit 3d55caf into master Aug 17, 2017
@joshwiens
Copy link
Member

FYI - You have access to merge, it takes owner level access to override the checks.

@boopathi
Copy link
Member Author

I still need permission to push to master for release commits. How are release commits pushed to master in webpack-contrib?

@pi0
Copy link

pi0 commented Aug 18, 2017

@boopathi Just as a question, the package is released as 0.0.0 is it just for some internal reasons or not stable yet?

@boopathi
Copy link
Member Author

The first version will be 0.2.0 - mostly keeping it the same version as babel-minify(0.2.0)

@pi0
Copy link

pi0 commented Aug 18, 2017

OK so will wait for 0.2.0 before integrating with nuxt :)) Thanks for your hard work.

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