Greetings! Thanks for new way to optimise web bundles!
And.. first problem, I tried to add plugin to existing project and got no such file
errors:
ERROR in ./~/lodash/fp/filter.js
Module build failed: Error: ENOENT: no such file or directory, open '/path-to-project/node_modules/lodash/fp/_arrayFilter.js'
at Error (native)
@ ./path-to-file.js 68:15-42
ERROR in ./~/lodash/fp/map.js
Module build failed: Error: ENOENT: no such file or directory, open '/path-to-project/node_modules/lodash/fp/_arrayMap.js'
at Error (native)
@./path-to-file.js 88:12-36
ERROR in ./~/lodash/_MapCache.js
Module build failed: Error: ENOENT: no such file or directory, open '/path-to-project/node_modules/lodash/_ListCache.js'
at Error (native)
@ ./~/lodash/_SetCache.js 1:15-37
ERROR in ./~/lodash/_Stack.js
Module build failed: Error: ENOENT: no such file or directory, open '/path-to-project/node_modules/lodash/_ListCache.js'
at Error (native)
@ ./~/lodash/_baseIsEqualDeep.js 1:12-31
It's happened only in one file where i've used lodash/fp
const composeAddress = fp.flow(fp.map(fp.trim), fp.compact, fp.join(' '));
const cleanupCoordinates = fp.flow(fp.map(fp.toNumber), fp.filter(fp.isFinite));
const cleanupSearchQuery = fp.flow(fp.trim, fp.toLower);
And with this methods:
_.isEqual
[797] ./~/lodash/isEqual.js 984 bytes {0} [built]
[798] ./~/lodash/_baseIsEqual.js 1.13 kB {0} [built]
[799] ./~/lodash/_baseIsEqualDeep.js 3 kB {0} [built] [1 error]
_.union
[648] ./~/lodash/union.js 750 bytes {0} [built]
[649] ./~/lodash/_baseFlatten.js 1.2 kB {0} [built]
[650] ./~/lodash/_arrayPush.js 437 bytes {0} [built]
[651] ./~/lodash/_isFlattenable.js 489 bytes {0} [built]
[652] ./~/lodash/isArguments.js 1.29 kB {0} [built]
[653] ./~/lodash/isArrayLikeObject.js 742 bytes {0} [built]
[654] ./~/lodash/isArrayLike.js 875 bytes {0} [built]
[655] ./~/lodash/_getLength.js 444 bytes {0} [built]
[656] ./~/lodash/_baseProperty.js 351 bytes {0} [built]
[657] ./~/lodash/isFunction.js 1.18 kB {0} [built]
[658] ./~/lodash/isObject.js 727 bytes {0} [built]
[659] ./~/lodash/isLength.js 808 bytes {0} [built]
[660] ./~/lodash/_baseUniq.js 1.91 kB {0} [built]
[661] ./~/lodash/_SetCache.js 508 bytes {0} [built] [1 error]
But after I removed all relations to lodash/fp
i still had this problems
ERROR in ./~/lodash/_MapCache.js
Module build failed: Error: ENOENT: no such file or directory, open '/path-to-project/node_modules/lodash/_ListCache.js'
at Error (native)
@ ./~/lodash/_SetCache.js 1:15-37
ERROR in ./~/lodash/_Stack.js
Module build failed: Error: ENOENT: no such file or directory, open '/path-to-project/node_modules/lodash/_ListCache.js'
at Error (native)
@ ./~/lodash/_baseIsEqualDeep.js 1:12-31
Here my configurations:
package.json
(removed all non webpack/babel or production libs):
{
"devDependencies": {
"autoprefixer": "6.3.6",
"babel-cli": "6.8.0",
"babel-core": "6.8.0",
"babel-eslint": "6.0.4",
"babel-loader": "6.2.4",
"babel-plugin-add-module-exports": "0.2.0",
"babel-plugin-lodash": "3.1.0",
"babel-plugin-react-transform": "2.0.2",
"babel-plugin-transform-class-properties": "6.8.0",
"babel-plugin-transform-decorators-legacy": "1.3.4",
"babel-plugin-transform-es2015-classes": "6.8.0",
"babel-plugin-transform-es3-member-expression-literals": "6.8.0",
"babel-plugin-transform-es3-property-literals": "6.8.0",
"babel-plugin-transform-flow-strip-types": "6.8.0",
"babel-plugin-transform-node-env-inline": "6.8.0",
"babel-plugin-transform-runtime": "6.8.0",
"babel-preset-es2015": "6.6.0",
"babel-preset-react": "6.5.0",
"babel-preset-react-hmre": "1.1.1",
"babel-preset-stage-0": "6.5.0",
"babel-register": "6.8.0",
"babel-runtime": "6.6.1",
"clean-webpack-plugin": "0.1.9",
"css-loader": "0.23.1",
"file-loader": "0.8.5",
"html-webpack-plugin": "2.16.1",
"json-loader": "0.5.4",
"less": "2.6.1",
"less-loader": "2.2.3",
"lodash-webpack-plugin": "0.1.1",
"postcss": "5.0.21",
"postcss-loader": "0.9.1",
"source-map-support": "0.4.0",
"style-loader": "0.13.1",
"url-loader": "0.5.7",
"webpack": "1.13.0",
"webpack-dev-middleware": "1.6.1",
"webpack-hot-middleware": "2.10.0"
},
"dependencies": {
"lodash": "4.11.2"
}
}
webpack.config.js
const webpack = require('webpack');
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
module.exports = {
context: __dirname,
entry: './src/index.js',
output: {
path: DIST_DIR_PATH,
publicPath: '/' + DIST_DIR_NAME + '/',
filename: '[hash]-bundle.js',
chunkFilename: '[chunkhash]-bundle.js'
},
postcss: function () {
return [
autoprefixer({
browsers: [
'Firefox > 20',
'last 3 version'
]
})
];
},
module: {
loaders: [
{test: /\.html$/, loader: 'html'},
{test: /\.json$/, loader: 'json'},
{test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url?limit=10000&minetype=application/font-woff'},
{test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url?limit=10000'},
{test: /\.(jpe?g|png|gif)$/i, loader: 'url?limit=10000'},
{test: /\.css$/, include: /flexboxgrid/, loader: 'style!css?modules'},
{test: /\.js$/, loader: 'babel', exclude: /node_modules/},
{test: /\.css$/, exclude: /flexboxgrid/, loaders: ['style', 'css', 'postcss']},
{test: /\.less/, exclude: /flexboxgrid/, loaders: ['style', 'css', 'postcss', 'less']}
]
},
amd: {
jQuery: true
},
plugins: [
new LodashModuleReplacementPlugin(),
new IgnorePlugin(new RegExp('^(vertx)$')),
new LimitChunkCountPlugin({
maxChunks: 20
}),
new HtmlWebpackPlugin({
inject: 'body',
title: 'Wing',
template: './assets/index.ejs',
favicon: './assets/favicon.ico'
}),
new DedupePlugin(),
new CleanWebpackPlugin('*', {
root: DIST_DIR_PATH
}),
new UglifyJsPlugin({
sourceMap: false,
compress: {
warnings: false
},
output: {
comments: false
}
}),
new DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
})
]
};
.babelrc
{
"presets": [
"stage-0",
"es2015",
"react"
],
"plugins": [
"lodash",
"add-module-exports",
"transform-class-properties",
"transform-decorators-legacy",
"transform-runtime",
"transform-node-env-inline",
"transform-es3-property-literals",
"transform-es3-member-expression-literals",
[
"transform-es2015-classes",
{
"loose": true
}
]
]
}