Skip to content

Commit

Permalink
Remove hints about possibly not needing babel.cherryPick due to Webpa…
Browse files Browse the repository at this point in the history
…ck 2 tree shaking, as this doesn't currently appear to be true
  • Loading branch information
insin committed Jan 24, 2017
1 parent 3d384d9 commit 7950ddf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 32 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
**Removed:**

- Remove hints about possibly not needing `babel.cherryPick` due to Webpack 2 tree shaking, as this doesn't currently appear to be true.

# 0.15.0 / 2017-01-25

**Breaking Changes:**
Expand Down
4 changes: 0 additions & 4 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ module.exports = {
##### `cherryPick`: `String | Array<String>`

> As of v0.15 nwb uses Webpack 2, which can tree shake ES modules (to a degree) to avoid including unused imports in the bundles it creates. If a module you're importing has a `"module"` entry in its `package.json` which points to a build using ES modules, you might not need to use `cherryPick`.
>
> Running `nwb check-config` will tell you if any modules you've configured `cherryPick` for might be suitable for Webpack 2 to handle instead.
**Note:** this feature only works if you're using ES6 `import` syntax.

Module names to apply `import` cherry-picking to.
Expand Down
29 changes: 1 addition & 28 deletions src/getUserConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import util from 'util'
import chalk from 'chalk'
import figures from 'figures'
import glob from 'glob'
import resolve from 'resolve'
import webpack from 'webpack'

import {CONFIG_FILE_NAME, PROJECT_TYPES} from './constants'
import {COMPAT_CONFIGS} from './createWebpackConfig'
import debug from './debug'
import {ConfigValidationError} from './errors'
import {deepToString, joinAnd, typeOf} from './utils'
import {deepToString, typeOf} from './utils'

const DEFAULT_REQUIRED = false

Expand Down Expand Up @@ -196,32 +195,6 @@ export function processUserConfig({
}
}

if ('cherryPick' in userConfig.babel) {
let {cherryPick} = userConfig.babel
if (typeOf(cherryPick) === 'string') {
cherryPick = [cherryPick]
}
let esModules = []
cherryPick.forEach(mod => {
try {
let pkg = require(resolve.sync(`${mod}/package.json`, {basedir: process.cwd()}))
if (pkg.module) {
esModules.push(mod)
}
}
catch (e) {
// pass
}
})
if (esModules.length > 0) {
let n = esModules.length
report.hint('babel.cherryPick',
`${joinAnd(esModules)} ${s(n, 'has,have')} a ${chalk.cyan('"module"')} entry in ${s(n, 'its,their')} ${chalk.cyan('package.json')}.`,
`If you're using ES modules, You Might Not Need ${chalk.green('babel.cherryPick')} for ${s(n, 'this,these')} module${s(n)}, as Webpack 2 can tree shake ES modules.`,
)
}
}

// Karma config
// TODO Remove in a future version
if (userConfig.karma.testDir || userConfig.karma.testDirs) {
Expand Down

0 comments on commit 7950ddf

Please # to comment.