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

False-positive "ERROR: Runtime dependency 'prettier' found in devDependencies." when using Lerna / Yarn workspaces #435

Open
tommedema opened this issue Aug 20, 2018 · 0 comments

Comments

@tommedema
Copy link

tommedema commented Aug 20, 2018

This is a Bug Report

Description

For bug reports:

  • What went wrong?

When using yarn workspaces with lerna (see an example repo of this setup here), where a serverless app is one of my packages, there are issues when determining the dependency graph. One of the serverless' apps workspace packages depends on prettier during runtime, and this is defined in dependencies:

packages/my-package/package.json

  "dependencies": {
    ...
    "@types/prettier": "^1.13.1",
    "prettier": "^1.13.5",
    ...
  }

At the same time other packages depend on prettier but for development purposes only, including my serverless app.

packages/my-serverless-service/package.json

  "devDependencies": {
    ...
    "@types/prettier": "^1.13.1",
    "prettier": "^1.13.5",
    ...
  }
  • What did you expect should have happened?

Serverless webpack should not complain that prettier is in devDependencies of my-serverless-service, because it is only used during runtime of package my-package, which does include it under dependencies. Note that my-serverless-service does depend on my-package.

  • What was the config you used?

webpack.config.js

const path = require('path')
const slsw = require('serverless-webpack')
const nodeExternals = require('webpack-node-externals')

const entries = {}

Object.keys(slsw.lib.entries).forEach(
  key => (entries[key] = ['./source-map-install.js', slsw.lib.entries[key]])
)

module.exports = {
  mode: slsw.lib.webpack.isLocal ? 'development' : 'production',
  entry: entries,
  // We use webpack-node-externals to excludes all node deps.
  // You can manually set the externals too.
  externals: [nodeExternals()],
  devtool: 'source-map',
  resolve: {
    extensions: ['.js', '.jsx', '.json', '.ts', '.tsx']
  },
  output: {
    libraryTarget: 'commonjs',
    path: path.join(__dirname, '.webpack'),
    filename: '[name].js'
  },
  target: 'node',
  module: {
    rules: [
      // all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
      { test: /\.tsx?$/, loader: 'ts-loader' }
    ]
  }
}

serverless.yml

custom:
  webpack:
    packager: yarn
    
    # enable auto-packing of external modules
    includeModules:
      forceExclude:
        - aws-sdk
  • What stacktrace or error message from your provider did you see?
$ serverless deploy --verbose --max-old-space-size=4096
Serverless: Using configuration:
{
  "packager": "yarn",
  "includeModules": {
    "forceExclude": [
      "aws-sdk"
    ]
  },
  "webpackConfig": "webpack.config.js",
  "packagerOptions": {}
}
Serverless: Removing /Users/my-project/packages/serverless-diy-bucket/.webpack
Serverless: Bundling with Webpack...
Time: 59054ms
Built at: 2018-08-20 09:28:30
               Asset      Size  Chunks             Chunk Names
    src/transform.js   3.2 MiB       0  [emitted]  src/transform
src/transform.js.map  4.53 MiB       0  [emitted]  src/transform
Entrypoint src/transform = src/transform.js src/transform.js.map
   [0] /Users/my-project/node_modules/aws-sdk/lib/core.js 2.17 KiB {0} [built]
   [1] /Users/my-project/node_modules/aws-sdk/lib/node_loader.js 3.23 KiB {0} [built]
  [14] external "path" 42 bytes {0} [built]
  [50] external "util" 42 bytes {0} [built]
  [63] external "fs-extra" 42 bytes {0} [built]
 [262] multi ./source-map-install.js ./src/transform.ts 40 bytes {0} [built]
 [263] ./source-map-install.js 40 bytes {0} [built]
 [264] external "source-map-support" 42 bytes {0} [built]
 [265] ./src/transform.ts 4.1 KiB {0} [built]
 [266] /Users/my-project/node_modules/aws-sdk/lib/aws.js 159 bytes {0} [built]
 [835] ../vgcli/dist/index.js 3.99 KiB {0} [built]
 [836] ../sketch-to-canvas/dist/index.js 264 bytes {0} [built]
 [898] ../canvas-to-grid-tree/dist/index.js 10.5 KiB {0} [built]
 [899] ../grid-to-react/dist/index.js 246 bytes {0} [built]
[1369] external "uuid/v4" 42 bytes {0} [built]
    + 1355 hidden modules
Serverless: Fetch dependency graph from /Users/my-project/packages/serverless-diy-bucket/package.json
Serverless: ERROR: Runtime dependency 'prettier' found in devDependencies. Move it to dependencies or use forceExclude to explicitly exclude it.

  Serverless Error ---------------------------------------

  Serverless-webpack dependency error: prettier.

Additional Data

  • Serverless-Webpack Version you're using:
    5.2.0

  • Webpack version you're using:
    4.16.5

  • Serverless Framework Version you're using:
    Serverless Version: 1.30.0

  • Operating System:
    OS: darwin
    Node Version: 8.11.3

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

No branches or pull requests

2 participants