Webpack 4 support (@NPM: ^5.0.0-rc.4)
julianosam opened this issue ยท 11 comments
Hi. I'm trying out the plugin using webpack 4.0.1 and I noticed a strange behavior using webpackIncludeModules
options in conjunction with [nodeExternals()]
in webpack config. For some reason, the build completes successfully but it does not include any external modules being imported in the code. It used to work just fine with webpack 3 and any module declared as a dependency were included under the node_module folder inside the package zip file.
So my question is: is webpack 4 supported? If it is, is there any additional configuration? Let me know if you need more information on this issue:
serverless-webapck version: 4.3.0
webpack version: 4.0.1
serverless.yml
service:
name: pibot
plugins:
- serverless-webpack
- serverless-offline
provider:
name: aws
runtime: nodejs6.10
environment: ${file(./config/env.yml)}
functions:
(...)
package:
individually: true
exclude:
- src/**/*.spec.ts
custom:
webpackIncludeModules: true
webpack.config.js
const path = require('path');
const slsw = require('serverless-webpack');
const nodeExternals = require('webpack-node-externals')
module.exports = {
entry: slsw.lib.entries,
devtool: 'source-map',
externals: [nodeExternals()],
resolve: {
extensions: [
'.js',
'.jsx',
'.json',
'.ts',
'.tsx'
]
},
mode: 'production',
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, '.webpack'),
filename: '[name].js',
},
target: 'node',
module: {
rules: [
{ test: /\.ts(x?)$/, loader: 'ts-loader' },
],
}
};
package.json (dependencies)
"dependencies": {
"@slack/client": "3.16.0",
"jsonpath": "1.0.0",
"request": "2.83.0",
"typescript-ioc": "1.1.0"
},
Hi @julianosam . Webpack 4 is not yet supported. It will be done with serverless-webpack version 5.0.0, which is already on the horizon. The new version will drop support of webpack 2 in favor of webpack 4.
There is already a fix in PR #328. Could you do me a favor and try to use "serverless-webpack":"github:janicduplessis/serverless-webpack#webpack-modules"
and report back if webpack 4 works with that PR?
Changed the subject back to the first version. We'll keep this issue as master issue for Webpack 4 support and serverless-webpack version 5.0.0!
Pardon the ignorant question, but if webpack 4 isn't supported.. why does this plugin install it then? Would it not make sense to pin the dependency at webpack 2.x (or webpack 3.x)?
Exactly ๐ . Together with the upcoming 4.4.0 release I will restrict the webpack peer dependency to < 4.0.0
. At the time of the 4.3.0 release I did not know that it will break yet.
Additionally I will release a 5.0.0-rc.1
with webpack 4 support
Ahh ok. ๐ Thanks!
@HyperBrain Tested here with the latest code. So far so good. Dependencies are being included correctly. Looking forward to the release! Let us know if you need any help!
At all here, @janicduplessis and @serverless-heaven/serverless-webpack-contributors :
I did a pre release based on 4.4.0 and published a new 5.0.0-rc.1
to npm. It includes #328 which enables Webpack 4 support and was done out from the v5
branch. Can you try to use ^5.0.0-rc.1
and report any Webpack 4 related issues you find here? Referencing it as caret will let you get any updates from rc's to the final version automatically :)
I upgraded one of our projects to Webpack 4. So far everything works properly. The only additional work was to upgrade/update the loaders and webpack plugins properly (especially the babel-loader to ^7.1.3
and the copy-webpack-plugin to ^4.5.0
)
5.0.0-rc.3
5.0.0-rc.4
is most likely the very last rc for v5. Please use it and report any issues. Otherwise I'll go for the release end of this week ๐
Released with 5.0.0