diff --git a/CHANGES.md b/CHANGES.md index 473c6996..1f9a57c6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,10 @@ - postcss-loader: v1.2.1 → [v1.2.2](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#122) - webpack-merge: v2.3.1 → [v2.4.0](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#240--2017-01-12) +**Internal:** + +- Use ES2015 `String` methods available in Node.js v4 instead of `String.prototype.indexOf` comparisons. + # 0.14.1 / 2017-01-13 **Fixed:** diff --git a/src/createWebpackConfig.js b/src/createWebpackConfig.js index b3861ba2..dea6f0c5 100644 --- a/src/createWebpackConfig.js +++ b/src/createWebpackConfig.js @@ -15,7 +15,7 @@ import merge from 'webpack-merge' import HashedModuleIdsPlugin from '../vendor/HashedModuleIdsPlugin' import createBabelConfig from './createBabelConfig' import debug from './debug' -import {deepToString, endsWith, typeOf} from './utils' +import {deepToString, typeOf} from './utils' import StatusPlugin from './WebpackStatusPlugin' // Top-level property names reserved for webpack config @@ -69,7 +69,7 @@ export let loaderConfigFactory = (buildConfig, userConfig) => */ export let styleLoaderName = (prefix) => (name) => { - if (prefix && endsWith(prefix, name)) { + if (prefix && prefix.endsWith(name)) { return prefix } return prefix ? `${prefix}-${name}` : name @@ -254,7 +254,7 @@ function injectManifestPlugin() { this.plugin('compilation', (compilation) => { compilation.plugin('html-webpack-plugin-before-html-processing', (data, cb) => { Object.keys(compilation.assets).forEach(key => { - if (key.indexOf('manifest.') !== 0) return + if (!key.startsWith('manifest.')) return let {children} = compilation.assets[key] if (children && children[0]) { data.html = data.html.replace( @@ -346,7 +346,7 @@ export function createPlugins(server, buildConfig = {}, userConfig = {}) { minChunks(module, count) { return ( module.resource && - module.resource.indexOf('node_modules') !== -1 + module.resource.includes('node_modules') ) } })) diff --git a/src/utils.js b/src/utils.js index adde4eff..427acffa 100644 --- a/src/utils.js +++ b/src/utils.js @@ -55,13 +55,6 @@ export function deepToString(object) { return util.inspect(object, {colors: true, depth: null}) } -/** - * String.prototype.endsWith() is behind the --harmony flag in Node.js v0.12. - */ -export function endsWith(s1, s2) { - return s1.lastIndexOf(s2) === s1.length - s2.length -} - /** * Get a list of nwb plugin names passed as arguments. * @param {Object} args parsed arguments. diff --git a/src/webpackUtils.js b/src/webpackUtils.js index cff40624..5c1e9981 100644 --- a/src/webpackUtils.js +++ b/src/webpackUtils.js @@ -57,7 +57,7 @@ function formatMessage(message) { } function isLikelyASyntaxError(message) { - return message.indexOf(FRIENDLY_SYNTAX_ERROR_LABEL) !== -1 + return message.includes(FRIENDLY_SYNTAX_ERROR_LABEL) } function formatMessages(messages, type) {