Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack 4 support (@NPM: ^5.0.0-rc.4) #331

Closed
julianosam opened this issue Feb 28, 2018 · 11 comments · Fixed by #338
Closed

Webpack 4 support (@NPM: ^5.0.0-rc.4) #331

julianosam opened this issue Feb 28, 2018 · 11 comments · Fixed by #338
Labels
Milestone

Comments

@julianosam
Copy link

julianosam commented Feb 28, 2018

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"
  },
@julianosam julianosam changed the title Webpack 4 support Webpack 4 support using webpackIncludeModules Feb 28, 2018
@HyperBrain
Copy link
Member

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?

@HyperBrain HyperBrain added this to the 5.0.0 milestone Feb 28, 2018
@HyperBrain HyperBrain changed the title Webpack 4 support using webpackIncludeModules Webpack 4 support Feb 28, 2018
@HyperBrain
Copy link
Member

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!

@ffxsam
Copy link

ffxsam commented Mar 1, 2018

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)?

@HyperBrain
Copy link
Member

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.

@HyperBrain
Copy link
Member

Additionally I will release a 5.0.0-rc.1 with webpack 4 support

@ffxsam
Copy link

ffxsam commented Mar 1, 2018

Ahh ok. 😄 Thanks!

@julianosam
Copy link
Author

@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!

@HyperBrain HyperBrain changed the title Webpack 4 support Webpack 4 support (@NPM: ^5.0.0-rc.1) Mar 2, 2018
@HyperBrain
Copy link
Member

HyperBrain commented Mar 2, 2018

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 :)

@HyperBrain
Copy link
Member

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)

@HyperBrain HyperBrain changed the title Webpack 4 support (@NPM: ^5.0.0-rc.1) Webpack 4 support (@NPM: ^5.0.0-rc.2) Mar 6, 2018
@HyperBrain HyperBrain changed the title Webpack 4 support (@NPM: ^5.0.0-rc.2) Webpack 4 support (@NPM: ^5.0.0-rc.3) Mar 7, 2018
@HyperBrain
Copy link
Member

HyperBrain commented Mar 7, 2018

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 😄

@HyperBrain HyperBrain changed the title Webpack 4 support (@NPM: ^5.0.0-rc.3) Webpack 4 support (@NPM: ^5.0.0-rc.4) Mar 7, 2018
@HyperBrain HyperBrain mentioned this issue Mar 8, 2018
Merged
7 tasks
@HyperBrain
Copy link
Member

Released with 5.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants